CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 1999
    Posts
    18

    creating DB's in mySQL

    I would like to create an applet wich retrieves information from a mySQL-database.

    I downloaded mySQL and a class IV driver, but I can't figure out how to create a database.

    Could anyone help me ?

    Jesper


  2. #2
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: creating DB's in mySQL


    I dont know about mySQL and class IV driver. but i hope the SQL statement is common for
    all database and drivers.

    > how to create a database



    CREATE DATABASE Test
    ON (NAME = TestData, // Logical Name of the Database
    FILENAME = 'e:\mssql7\data\TestData.mdf', // Physical file name
    SIZE = 100MB,
    MAXSIZE = 200,
    FILEGROWTH = 20)





    > retrieves information from a mySQL-database

    You have to run a specific System Stored Procedures to get the information about the database.
    ( Some are : sp_tables , sp_columns , ... )

    In java , do the following to call the stored procedure.



    CallableStatement tCallableStatement = tDBConnection.prepareCall( "sp_table" );
    ResultSet tResultSet = tCallableStatement.executeQuery();





    Now manipulate with the ResultSet object to get the information about the tables in
    a particular database.

    Poochi...


  3. #3
    Join Date
    Sep 1999
    Posts
    18

    Re: creating DB's in mySQL

    Hi Poochi - thanks for responding !

    I just wondered - the 'CREATE DATABASE Test...' part of the code you send me is not supposed to be type into a java-app, but rather in a SQL-program, right ?

    Jesper


  4. #4
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: creating DB's in mySQL



    Yes , it's a SQL Statement. You can use it in java .. Try like this..



    String SQLString = "CREATE DATABASE ...... "
    Statement tStatement = m_tDBConnection.createStatement();
    tStatement.executeUpdate( SQLString );
    tStatement.close();






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured