Create new MySQL Database with SQL

I have a simple question, :-)
how can I create a new MySQL Database with SQL - (JDBC)
can you show me a code example?
tank you ...

okay ... but how do I use the URL ??? that's the problem
I tried this:
Connection con   = null;
        Vector vct       = new Vector();
        try{
            String drv = "org.gjt.mm.mysql.Driver";
            String url = "jdbc:mysql://111.222.333.444:3306";
            String name = "myname";
            String pass = "mypass";
            Class.forName(drv);
            con = DriverManager.getConnection(url,name,pass);
            String statement = "CREATE DATABASE TestDB_Don1";
            Statement stm = con.createStatement();
            stm.execute(statement);
            stm.close();
            con.close();                         
        catch(Exception e){ e.printStackTrace(); }but it doesen't work ............. what is wrong ?

Similar Messages

  • Creating A New MySQL Database With Coldfusion Code

    Hi,
    I was wondering if anyone knew how to create a whole entire
    new database simply by executing a Coldfusion template (via a form
    for example).
    I'm pretty confident at creating a new table in an already
    existing database but not sure how to go about creating an entirely
    new database from pure ColdFusion code using MySQL.
    I basically want to create some portal for myself to do this
    to save on arduous time. It'll need to be a form because I'll have
    to give it a name, username, password etc. I need the seperate
    databases for my separate clients you see.
    One point I should make is that it is on a shared server so I
    don't have direct access to the CF Administrator.
    Any advice on achieving this or highlighting the pitfalls
    would be greatly appreciated.
    Many thanks in advance!
    Michael.

    quote:
    Originally posted by:
    Sabaidee
    if it is on a shared server, then you very likely do not have
    enough permissions to create new batabases in MySQL either...
    is there an option for you in your hosting control panel (or
    whatever it is called) to create a new MySQL database for your
    account without any involvement of server admins? if so then,
    technically you may be able to create a new db programmatically.
    but i doubt you can...
    I know it sounds cheeky but any chance you could supply
    example code for doing this with ColdFusion and MySQL? This way I
    will then be able to try it rather than waiting for my host to get
    back to me.
    I would have tried doing it already because I use SQL quite
    often with queries etc, but I just don't have the technical know
    how for this specific task at hand.
    Many thanks for your help!

  • Create New Test Database with all permissions

    Hi all,
    We have a Oracle9i database running on Linux platform . Currently 40 users working on it. Now i want to create another test database with giving all permissions to it. Give your valuable suggestions.
    Regards,
    Sudarshanam

    The answer to your question as I understand now would be,
    grant DBA to <user>;
    But I think you mean something else. Please be more clear

  • MySQL database with SQL Toolkit

    Hi,
    we are using CVI 2012 and the SQL Toolkit 2.2 and we want to connect to a MySQL database.
    The MySQL database was created with MySQLServer. When we try to connect with DBConnect we get an error.
    How can we connect the MySQL Database?
    What do we have to type in the connection string in DBConnect? Is it the name of the database, the path to the database or anything else?
    Does any one have experience with the SQL toolkit?
    Thanks in advance
    Oliver
    Solved!
    Go to Solution.

    You need to install the mysql connector odbc and then create an ODBC dns for your database.
    control panel, administrative, odbc

  • Create new oracle database with JAVA

    Hi!
    I would appreciated it if you could help me to solve a problem that i have.
    I am trying to create a new oracle database by a JAVA 1.4.2 application. I am using the scripts that Oracle 10.g supplies during the creation of a new database from the server (Generate Database Creation Scripts) with the appropriate changes, generated by a java application. Unfortunately, i am unable to connect with the database and the listener. Is there any other way to create a new database by java and how can i solve my current problem with the oracle scripts?
    Thank you.

    A) To create a new schema, you need to be connected as a user that has create schema privilege, or as tyhe user who is to own the schema (remembering that the user has appropriate create privs, as seen in the GRANT command in the SQL Reference manual). Not an issue at all, I think, if you coordinate this with your DBA. Discussed very well in the Administrator's manual.
    B) Alternately, you could create a complete copy of the schema, including all desired objects (tables, views, etc.) in a separate database and simply export the user and schema. Then simply invoke the OS-based import command (imp) to load that entire thing into the target database.
    C) To create a new database, there are 3 simple steps ...
    1) create the appropriate initialization parameter file
    the init{sid}.ora file should be placed in the $ORACLE_HOME/dbs or %ORACLE_HOME%\database directory. (I recommend you do not attempt to create the spfile.) Of critical interest will be setting the block size information, the control file parameters, and using the appropriate memory management parameters, based on the version of the software you will be using to create the database instance.
    2) start an empty instance, pointing to the parameter file
    This will be an OS specific call, and will require that you have the correct OS environment set up as well as access to the ORACLE_HOME which will provide the software that you will invoke. In *nix you will need to call the sqlplus command with sysdba provs and in Windows you will need to call oradim to initialize this as a service.
    3) run the SQL create database command
    You might want to use the dbca to create a template of the create database command, or look in the SQL Reference manual for the variations on the command. Of critical interest will be initializing the redo logs as well as the system, sysaux (if needed), temp and undo tablespaces after which you can set up the regular tablespaces, users and schemas. I highly recommend that you have redundant copies of the control files on separate drives.
    You may want to review the online Concepts manual and the Adminstration Guide for some of the specifics to your needs, but I think I've covered the basics.
    Remember that ideally you will only have one database instantiated on any given server as the memory and CPU overhead of each instance is significant.
    Good luck.

  • Importing XML database to create equivalent mysql database

    I have created an XML database.Now I need to create a MySQL database with similar structure.
    Due to it's nested structure and complex dependencies, I find it difficult to identify and design the tables and relations in MySQL(I fear of redundancies).
    So,I am looking for some tool or a way to create an equivalent MySQL database.
    Thanks.

    fine.
    But i think exp/imp binary don't support 9i to 10g import.
    so you using 10g export binary to take the 9i database full backup and import into 10g database use the 10g export binary.
    Regards
    Rajabaskar

  • Is it possible to insert data into a MySQL database with Java?

    Hello everyone!
    I would like to know, if it's possible to insert data into a MySQL database, with a JFrame inside a servlet?
    When the JFrame is first created it calls this method:
         * Connects the servlet with the MySQL database.
        private void connect(){
            try{
                Class.forName("com.mysql.jdbc.Driver");
                connection = DriverManager.getConnection(
                        "jdbc:mysql://localhost:3306/data", "root", "omfg123");
            }catch(ClassNotFoundException cnfe){
                cnfe.printStackTrace();
            }catch(SQLException sqle){
                sqle.printStackTrace();
        }Then, when you click the "Add" button, it executes this code:
                add.addActionListener(new ActionListener(){
                    @Override
                    public void actionPerformed(ActionEvent ae){
                        String employee = employeeName.getText();
                        String[] args = employee.split(" ");
                        firstName = args[0];
                        lastName = args[1];
                        execute();
                });And this is my "execute()" method:
         * Connects the servlet with the MySQL database.
         * - And executes the SQL queries.
        private void execute(){
            try{
                PreparedStatement statement = connection.prepareStatement("insert" +
                        " into employees values(" + firstName + ", " + lastName
                        + ")");
                ResultSet result = statement.executeQuery();
                String fullName = firstName + " " + lastName;
                printer.write("Employee " + fullName + " added.</br>");
            }catch(SQLException sqle){
                sqle.printStackTrace();
        }But when I click the "Add" button, nothing happens.

    This is what I use to insert into mysql. It works on windows.
    try {
                Class.forName("com.mysql.jdbc.Driver");
                String connectionUrl = "jdbc:mysql://" + loadip + "/custsig?" +
                        "user=root&password=";
                Connection con = DriverManager.getConnection(connectionUrl);
                newproc = jTextField1.getText();
                newsoft = jTextField2.getText();
                newdeb = jTextField3.getText();
                newcust = jTextField4.getText();
                if (newcust.equals("")) {
                    errorsig12 = 1;
                    jLabel1.setForeground(new java.awt.Color(255, 0, 0));
                } else if (newsoft.equals("")) {
                    errorsig12 = 1;
                    jLabel2.setForeground(new java.awt.Color(0, 0, 0));
                } else if (newproc.equals("")) {
                    errorsig12 = 1;
                    jLabel3.setForeground(new java.awt.Color(0, 0, 0));
                } else if (newdeb.equals("")) {
                    errorsig12 = 1;
                    jLabel4.setForeground(new java.awt.Color(0, 0, 0));
                if (errorsig12 == 0) {
                    PreparedStatement ps = con.prepareStatement("insert into customer set cust_name = ?,  software = ?, processor = ?, debit = ?");
                    ps.setString(4, newdeb);
                    ps.setString(3, newproc);
                    ps.setString(2, newsoft);
                    ps.setString(1, newcust);
                    int rs = ps.executeUpdate();
            } catch (SQLException eg) {
                System.out.println("SQL Exception: " + eg.toString());
            } catch (ClassNotFoundException cE) {
                System.out.println("Class Not Found Exception: " + cE.toString());
            }

  • Is it possible to create a Clone database with the same name of source db ?

    Is it possible to create a Clone database with the same name of source db using RMAN ...
    DB version is 11.2.0.2
    Is it possible to clone a 11.2.0.2 database to 11.2.0.3 home location directly on a new server . If it starts in a upgrade mode , it is ok ....

    user11919409 wrote:
    Is it possible to create a Clone database with the same name of source db using RMAN ...
    yes
    >
    DB version is 11.2.0.2
    Is it possible to clone a 11.2.0.2 database to 11.2.0.3 home location directly on a new server . If it starts in a upgrade mode , it is ok ....yes
    Handle:     user11919409
    Status Level:     Newbie (10)
    Registered:     Dec 7, 2009
    Total Posts:     102
    Total Questions:     28 (22 unresolved)
    why do you waste time here when you rarely get any answers to your questions?

  • Try to use Mysql database with forte

    Dear All:
    As title said, I try to use Mysql database with forte.
    I read the manual , it said I have to put the database jdbc driver in
    the Forte for Java lib/ext directory.
    I did it and then add a new Driver in the Runtime tab in the Explorer
    window .
    But when I try to test this new driver(by Right-clicking on the driver
    or connection in the Explorer and select Test Driver from the context
    menu),it said "cannot find driver class: check your CLASSPATH or
    \lib\ext direectory".
    I am sure I'hve put the driver class(with the whole directory structure)
    in that folder.
    Does anyone what I may go wrong ?
    Could you please give me some advices that I can fix this problem ?
    Thanks in advance.
         Ken @ Taipei , Taiwan , Asia

    You should have put the jar file that contains the driver into that directory. If you unpacked the jar file and put the individual classes into that directory, it will not work.

  • Creating a Standby Database with the Same Directory Structure

    Hello gurus,
    I am self-learning the feature Oracle Data Guard, so I am testing it on Oracle 10g R2.
    At Oracle documentation there is a section F.4.: Creating a Standby Database with the Same Directory Structure*, that explains how to create a standby database with RMAN but there is something that I don´t understand:
    In the standby server, I created a database with the SID equal to production database* with the objetive to have the same directory structure, but when I try to startup nomount the standby database with pfile appear this expected error:
    ORA-16187: LOG_ARCHIVE_CONFIG contains duplicate, conflicting or invalid attributes
    So my question is: Is possible have the Same Directory Structure on both: Production and StandBy server?
    Thanks in advanced.

    Uwe and mseberg: thanks for your quick answers
    I have a doubt: How can you have the same directory structure if you have differents SIDs?, for example if you follow the OFA suggestions you would must have:
    On Production server: */u01/app/oracle/oradata/PRIMARY/system.dbf*
    On StandBy server: */u01/app/oracle/oradata/STANDBY/system.dbf*
    Or you created the directory structure manually on StandBy server? For example replacing the string STANDBY* to PRIMARY* before create the database using dbca.
    Do you understand my doubt? Excuse me for my english.
    Thanks.

  • Unbale to create new document part with same document number

    Number range assigned to the X Document Type is internal. I have created new document (0001) with Document Part 000 & Version 00. For same Document Number when i tried to create New Document part by mentioning Document Numner 0001, Document Part 001 and Version 00, it says Document Type X can be assigned to internal number range only.
    Even I tried with following selection....
    Document Number = Blank
    Document Part = 001
    Document Version = 00
    Template:
    Document = 0001
    Document Part = 000
    Document Version = 00
    Now system is creating document with new number i.e. 0002.  But we want to create another document part with same Document Number. What is the problem with internal number range for Document Number?

    Hi Pradeep,
    Following are the config parameter of the document type.
    CM Relevnce = blank
    Number assignmt= 01
    Internal Number Range =02
    External Number Range= blank
    Number Exit =MCDOKZNR
    Vers. No. Incr. =0
    Version Sequence = blank
    AlternativeScreen = blank
    Let me know if you need anything more.
    Edited by: JJSingh76 on Dec 7, 2010 7:25 PM

  • How to connect mySQL database with jdbc

    Who can tell me how to connect mySQL database with jdbc? Thanks

    http://onesearch.sun.com/search/developers/index.jsp?and=connect+mysql&nh=10&phr=&qt=&not=&field=title&since=&col=devforums&rf=0&Search.x=24&Search.y=16

  • How to connect MySql database with JSP

    Dear everyone,
    how to connect MySql database with JSP......

    It's too bad that nobody has ever asked this question before...

  • Configuring New Oracle Database with HFM Shared Services

    Hi,
    We have upgrated the oracle database to new version 11g. We are using HFM 11.1.1.3 version. When I tried to configure the new oracle database with existing HFM Shared Services, the EPM Configurator hangs. Please could you clarify the below few questions before start configuring the database.
    1. Do we want edit any properties or configuration files before starting the EPM Configurator?
    2. If we want to edit the reg.properties file, what is the password denotes in reg.properties file(Below is the structure of the reg.properties file)? Whether I need to give Oracle database schema password?
    jdbc.url=jdbc\:hyperion\:oracle\://xxxxx;
    password=?
    jdbc.driver=hyperion.jdbc.oracle.OracleDriver
    local.value=####
    username=schemaname
    Thanks,
    Aravindh K

    Is it a new database server you are trying to configure? As if it was just upgraded then you shouldnt need to do anything.
    If it is a new database server then have a read of the following doc in Oracle Support - "How To Change Shared Services Database Repository in EPM 11 [ID 976279.1]"
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Creating Multiple INSERT statements with SQL

    is there a way to create multiple INSERT staements with SQL .
    Example scenario : This is only example but i have lot of data in the real time.
    sql : Select Emplid from Table A where Emplid between 100 and 350 will retun me 50 rows . i want to insert those rows into another table.
    I am looking for output like below instead of Giving output just as EMPLIDs
    Insert into PS_LM_DATA ( EMPLID ) values ( 123 )
    Insert into PS_LM_DATA ( EMPLID ) values ( 234 )
    Insert into PS_LM_DATA ( EMPLID ) values ( 334 )
    and so on....
    thanks ,
    Karu

    If you are inserting into another table, you could use
    insert into PS_LM_DATA ( EMPLID ) 
    select Emplid from Table A where Emplid between 100 and 350Example:
    SQL> insert into emp2(empno) select empno from emp;
    14 rows created.
    SQL> insert into emp2(empno) select empno from emp where empno between 7369 and 7788;
    8 rows created.

Maybe you are looking for

  • IOS 7.0.4 ACTIVATE ERROR .My All works stuck now.

    Dear sir / Mis , i  have buy iphone 4 from owner its used iphone and i restore the iphone  to the new ios 7.0.4 and the device sittle linked with the previous owner  account and the phone locked in activation lock and ask me to enter the  apple id an

  • Custom page breaks with "@media print" in CSS when creating a PDF from HTML?

    Searching for threads containing the text string "@media print" gave me zero hits, so I guess I'm either the smartest guy in the entire universe for coming up with this idea or the dumbest for the same reason since I must be missing something that ev

  • INACTIVE Items in ASCP plan

    Hi, We are having a problem with Items with Inactive status code in source instance showing up in ASCP plan. Any idea what flags on items that Collection program will check during data pull? Thanks Sudhakar

  • How to replace a 6500 screen

    does anyone know how to get into a nokia 6500 classic fone so i can replace the screen??

  • Inventory management via batch number

    All of our products use Batch management. I noticed in Inventory Tracking/Stock Posting that the quantities are not separated out by batch #. We have to make adjustments between batch #s for the same item and reconcile the actual quantity with the B1