Executing mysql script file in java

Hello,
I am working on a research project that involves the creation of anywhere from 50 to 200 MySQL databases at a time. So far I am able to execute CREATE DATABASE commands successfully using the Statement.execute() command.
So onto my problem.....
I have the script files needed to create the tables for each database, but I cannot figure out how to run them through java. I am trying to execute a SOURCE /file_location/ statement, but I am getting "you have an error in your mysql syntax....".
Does anyone know if there is a way to execute a script file from java?

You mean to say that you have websphear application server (WAS) installed on Windows NT machine. Can you please share how you have deployed your application on WAS. The problem might be just because of configuration. What error/exception you are getting when you run application in WAS.

Similar Messages

  • Can I execute MySql's command from java application?

    Can I execute MySql's command from java application? And how?
    For example :
    load data local infile 'D:\\myData.txt'
    into table myTable
    fields terminated by ';'
    lines terminated by '\n';

    1. get the jdbc driver for mysql from the mysql site at: http://dev.mysql.com/downloads/connector/j/5.0.html
    2. follow the installation instructiions... which you'll also find in your mysql manual...
    Happy travels. Keith.

  • MySQL DB file using java

    Is there a way of creating a mySQL database file using java, a file similar to MS Access file?

    I recall a software that save files in .mysql format.
    Didn't know how these files were generated, but I am
    sure of the extension.Well that's swell.
    There is no such file used by MySQL. Further MySQL databases are not contained in a file but in fact use several files and are tied directly to tables. For each table you will have two files, one with structure and one with the data. Then for each index you will have another file.
    That's for MyISAM tables anyway (a MySQL variant of ISAM). For other table engine types it varies but multiple files per table is a common thread.
    The file you are talking about most likely contains SQL queries and is a SQL batch program for creating and populating a database.
    Anyway on to trying to actually resolve your issue. Creating ISAM files from scratch is a no-go to create a database. You can of course always connect to the database engine and issue queries like "CREATE DATABASE" or "CREATE TABLE"
    What is the actual problem you are trying to solve here?

  • Execute Unix script file using PL/SQL.

    Hi all,
    Is there a way to execute a PL/SQL procedure which call the Unix(AIX) OS script file.
    My version of Oracle is 7.3.
    Thanks.

    As Justin says, Java stored procedures is one way
    else if you dont know Java and are familiar with C,
    then you can create external routines in C
    and use them in procedure.
    Works with 8i and above( I believe)
    Cheers
    Ashwin N.

  • Executing the .bat file under java

    Hi,
    I have a batch file which will do some useful stuffs
    like compilation of jar file, deploying the ejb's under
    WebLogic container etc.
    I called the batch file under windows environment, it
    used to display the console without any processing
    on it.But similar stuff with shell script works fine on
    Linux OS.
    How do I execute the batch file from Runtime?

    We use
    Runtime.getRuntime().exec("c:\\path\\to\\batch.bat");
    If that doesn't work, try "cmd /c c:\\path\\to\\batch.bat".
    You might have to capture the output from the process from Java to make sure it works correctly. And yes, the downside is that it will bring up an empty command prompt when you run it under Windows 95,98,Me... not a lot you can do about that, it's avoidable under NT,2K,XP with a bit of trickery though.

  • How to execute a .exe file in java(Jsp) without using a process ???

    Hi All ,
    How to execute a .exe file in Jsp without using a process ??? ...
    Is it Possiable ????

    itsdhanasaraa wrote:
    But as this a web application ... By using Runtime i'm getting some probs ..
    Let me guess, you want your web application to run a program on the client and to your surprise that's not working?
    Ain't gonna happen.
    its taking more time to execute .... that's y is there any other option to execute .exe file other than Runtime.getRuntime().exec("filename");Write proper English and you may be taken more seriously.
    1) it's not "taking more time to execute", whatever that's supposed to mean.
    2) there's no other way to execute something. Not that you should every use even that way anyway
    3) whenever you start thinking of executing external programs from Java, start thinking of not using Java in the first place.

  • Java.io.filepermission error while executing a batch file from java prog

    Hi,
    i want run a java program which executes a batch file, both are in a jar file. while am trying this using webstart it shows error:access denied java.io.filepermission <<ALL FILES>>execute. why this happens how to rectify this.
    By
    Vinod

    Clearly, it would be a security vulnerability to be able to do such a thing from the web w/o user granting trust to the application.
    Java Web Start applications run in the Java SE secure sandbox unless they have been granted all-permissions by the user:
    1.) sign all jar files.
    2.) add <security><all-permissions/></security> to the jnlp file.
    The user would then be prompted to grant trust to the applications.
    /Andy

  • Need to execute tcl script from a Java Program

    Hello,
    I need to execute a tcl script from a Java Program. But I do not know how to call the tcl Interpreter. Can anybody help me?

    Iam using the exec command as follows:
    Process proc =
    rt.exec("C:/SpirentConnect/engines/tcl/8.3.4/windows/s
    ctcl.exe C:/Hello.tcl");
    But Hello.tcl is not executed.And does that exact string work on the command line?
    And what is the return code from running it?

  • Executing an HTML file within java program

    I want my java code to be able to open/execute an HTML file that I have. How do you do this?
    Thanks.

    You can display html in a java app, but it is not so simple to run a browser. What you want to look up is the WebBrowser class. Here is an excerpt from some code of mine that displays a url in the browser app in a panel, but there's some chaff in my code you would not be interested in (I'm using a card layout). You're better off loocing up org.jdesktop.jdic.browser which contains the WebBrowser class    /**
         * Reveal the container with the browser display. The browser display is
         * currently hidded using a CardLayout, so it is a simple matter to swap
         * displays; however, we put off actually loading the web page until the
         * first time the display is revealed.
         * @return true if the URL could be resolved and the given web page
         * displayed.
        public boolean showBrowser(
            java.net.URL pURL )
            // See if the web page component has not initialized.
            if ( pWebBrowser == null )
                pWebBrowser = new WebBrowser();
                pBrowserPane.setViewportView( pWebBrowser );
            if ( aLastURLVisited == null || ! aLastURLVisited.equals( pURL ) )
                pWebBrowser.refresh();
                pWebBrowser.setURL( pURL );
                aLastURLVisited = pURL;
            pDualLayout.show( pDualPanel, BROWSER_PANEL );
            return true;
        }

  • Executing WLST scripts through InstallAnyWhere Java code

    We are trying to execute WLST scripts (embedded java mode) through custom Java class of the InstallAnywhere. We could not able to succeed in that, gives error "Weblogic.Home" not found. After passing this parameter we got "WLST_offline" class not found. We have included Weblogic.jar & config.jar in the Insatllanywhere Path, now we are getting NPE in readTemplate command.
    Suggest us the right way to do so.
    Thanks

    Typically the environment is set up using a Domain's setDomainEnv.cmd or setDomainEnv.sh scripts, you may want to see if there is anything obvious in the script environment setup that you are missing.

  • Executing a .bat file from java code

    Im writing a utility and i need to be able to create and execute a .bat file from my program. I can create the .bat file fine but when i try to execute it nothing happens. I tried to use the following line of code to try to execute the .bat file (called make.bat) :
    try
    String parameterString = "\"C:\\WINNT\\System32\\cmd.exe\" C:\\ITS_Test\\make.bat";
    Runtime.getRuntime().exec(parameterString);
    catch (Exception e)
    System.out.println(e);
    The Runtime.getRuntime()exec() method worked fine when trying to execute an excel file but for some reason it dosen't want to work for the DOS prompt. Any ideas?

    Thanks everyone for all the replies.
    I have tried all the above with no luck. Im using netbeans, does anyone think that it could be a problem with the IDE.
    I tired the following code :
    String parameterString = "cmd.exe /C \"C:\\ITS_Test\\make.bat\"";
    Process pr = Runtime.getRuntime().exec(parameterString);
    pr.waitFor();
    This code does not throw any exceptions but just hangs. I also tried:
    String [] parameterString = {"cmd", "/c", "C:\\ITS_Test\\make.bat"};
    Process pr = Runtime.getRuntime().exec(parameterString);
    pr.waitFor();
    and:
    String parameterString = "\"C:\\WINNT\\System32\\cmd.exe\" \"C:\\ITS_Test\\make.bat\"";
    Process pr = Runtime.getRuntime().exec(parameterString);
    pr.waitFor();
    with the same result. Does anyone know why it just hangs and nothing happens (no exceptions thrown)?

  • How to execute an external file in java ?

    How to execute an external file , where the file name of the external file is in unicode character. (i,e, may be in Chinese character).

    Process p = Runtime.getRuntime().exec("/path/to/executable");
    This is write. But my question is while the file name is in Chinese font.
    It means while a file name is in Chinese font or any unicode character that are supported by window but not in the command prompt. In this case the file name is changed to ??????.doc like.
    So, while trying to execute this it shows File not found message.

  • Execute a .cmd file from Java program on tomcat which is running as service

    I have a .cmd/,.bat file which has to be executed depending on the parameters I pass through JSP page hosted on a tomcat instance.
    Tomcat is running as a windows service.
    I need my .cmd file to be opened in a cmd or DOS box so that user can interact with the dos window, which is mandatory.
    When I run the program from eclipse it works well but on the tomcat , the server side the output of the command is written to my log file and it gives no chance for users to monitor and interact with the command.
    Should I do something with log4j settings or is due to tomcat running as service?
    Please help.
    thanks

    thanks for the responses.
    But the design is like that.Then it needs to be fixed.
    I think this is why there's a shortage of people to write computer applications, they are all wasting their time struggling to implement bad designs.
    its a scheduler to be run on tomcat where we interact
    with the running batch files and can't be changed.A scheduler in Tomcat? Why run a scheduler in an application server?
    any help is appreciated.
    I tried to execute the batch file from servlet it
    runs , but i see the cmd.exe in windows task manager
    and need a dos box open.
    Any ideas?If you need a DOS box open then you need a signed-on user. So here's my patch:
    1. Write an application that listens for messages from this Tomcat scheduler, and when it receives those messages it does something in a DOS box.
    2. Have somebody sign on to the server and run that application.
    3. Change the Tomcat scheduler to send messages to that application instead of trying to actually run it.
    It's up to you what kind of messages you should send. There are plenty of choices.

  • Executing .sql scripts file from command prompt

    I had created the .sql scripts for
    --Create Database
    --Create tables
    --Create Stored procedure
    I am using SQL server 2008.
    Now i want to deploy it into the target server using the command prompt.
    How can I call to execute that script on the target server?

    with few errors as "Incorrect Syntax near "GO"".
    Hello,
    GO is a command, which is only known & interpretted by SSMS + SqlCmd.exe; SQL Server engine / data access components don't know this command, therefore you get an error.
    See
    Query Options Execution (General Page); for SSMS you can change it from GO to any other term.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How to execute a .cmd file in java

    I can execute an .bat or a .exe file.
    But .cmd file is not getting executed in java.
    Pls tell me how to do this

    You can solve this problem by using the following method:
      private String[] getEnvironmentVariables() {
        final Map<String, String> env = System.getenv();
        final String[] result = new String[env.size()];
        final StringBuilder buf = new StringBuilder(100);
        int i = 0;
        for (Entry<String, String> e : env.entrySet()) {
          buf.setLength(0);
          result[i++] = buf.append(e.getKey()).append('=').append(e.getValue()).toString();
        return result;
      }You just have to execute your command like this now:
    Runtime.exec("cmd /C " + getMyCommand(), getEnvironmentVariables(), getMyExecDirectory());The reason why "start" didn't work is, that it is a command executed in a shell, thus you need "cmd /C" to execute start in the cmd. So you can do this as well:
    Runtime.exec("cmd /C start " + getMyCommand(), getEnvironmentVariables(), getMyExecDirectory());If you want to to execute "myCommand" in an own process.
    Kind Regards,
    Stefan Schubert

Maybe you are looking for