Mysql and Java

Hi,
can you do me a favor got the following exception when I run the below code in the JBuilder4.
java.lang.NoClassDefFoundError: java/sql/Savepoint
     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
     at java.sql.DriverManager.getConnection(DriverManager.java:517)
     at java.sql.DriverManager.getConnection(DriverManager.java:177)
     at ucsc.Connect.main(Connect.java:17)
Exception in thread "main"
and When I run this program in the command prompt, I got the following exception
D:\>java Connect
Exception in thread "main" java.lang.NoClassDefFoundError: Connect
D:\>
I set CLASSPATH as %JAVA_HOME%\lib\jre\ mysql-connector-java-5.0.4-bin in the Environmental variables.
Can anyone please tell me the reason for that.
Code
Thanks
import java.sql.*;
   public class Connect
       public static void main (String[] args)
           Connection conn = null;
           try
               String userName = "root";
               String password = "";
               String url = "jdbc:mysql://localhost:3306/ucsc";
// ucsc is the database name      
               Class.forName ("com.mysql.jdbc.Driver");
               conn = DriverManager.getConnection(url,"root","");
               System.out.println ("Database connection established");
           catch (Exception e)
               System.err.println ("Cannot connect to database server");
           finally
               if (conn != null)
                   try
                       conn.close ();
                       System.out.println ("Database connection terminated");
                   catch (Exception e)
   }

Hi
Now I got the following message for that code
D:\>javac Connect.java
D:\>java Connect
Cannot connect to database server
D:\>
my code
import java.sql.*;
import javax.sql.*;
   public class Connect
       public static void main (String[] args)
           Connection conn = null;
           try
               String userName = "root";
               String password = "";
               String url = "jdbc:mysql://localhost:3306/ucsc";
               Class.forName ("com.mysql.jdbc.Driver");
               conn = DriverManager.getConnection (url, userName, password);
               System.out.println ("Database connection established");
           catch (Exception e)
               System.err.println ("Cannot connect to database server");
           finally
               if (conn != null)
                   try
                       conn.close ();
                       System.out.println ("Database connection terminated");
                   catch (Exception e) { /* ignore close errors */ }
   }can you tell me the where the error is
Thanks

Similar Messages

  • MySQL and Java - getting program to work

    I am setting up mysql to run sql from a Java program on my pc at home and probably biting off more than I can chew. I get these messages when executing the java program ExecuteSQL.java:
    Exception in thread "main" java.lang.NoClassDefFoundError: Test2 <wrong name: MyProjects/test2/Test2>
    at java.lang.ClassLoader.defineClass0<Native Method>
    at java.lang.ClassLoader.defineClass<Unknown Source>
    at java.security.SecurityClassLoader.defineClass<Unknown Source>
    at java.net.URLClassLoader.defineClass<Unknown Source>
    at java.net.URLClassLoader.access$100<Unknown Source>
    at java.net.URLClassLoader$1.run<Unknown Source>
    at java.security.AccessController.ddPrivileged<Native Method>
    at java.lang.ClassLoader.findClass<Unknown Source>
    at java.lang.ClassLoader.loadClass<Unknown Source>
    at sun.misc.Launcher$AppClassLoader.loadClass<Unknown Source>
    at java.lang.ClassLoader.loadClass<Unknown Source>
    at java.lang.ClassLoader.loadClassInternal<Unknown Source>
    This is what I did.
    I created a folder on my C: drive named MySQL.
    I downloaded these two zip files form the MySQL website
         * mysql-connector-java-3.0.11-stable
         * mysql-4.0.18-win.zip
    Installed both of these in folder MySQL.
    I modified this line in the program ("ExecuteSQL" 1st pgm in chapter 17) I got from "Java Examples In a Nutshell" and compiled it into directory jwork.
    String driver = "com.mysql.jdbc.driver", url = "jdbc:mysql://", user = "", password = "";
    The readme file talks about putting a jar file in $JAVA_HOME/jre/lib/ext.
    the word "Java_Home" (I now know) is not literally the name but represents the
    name of the folder where the JDK to be used exists. So I put a copy of
    mysql-connector-java-3.0.11-stable-bin.jar in folder C:\JDK14/jre/lib/ext.
    Then I get a ClassNotFoundException error com.mysql.jdbc.driver.
    After finding
    http://forum.java.sun.com/thread.jsp?forum=31&thread=439796
    and
    http://forum.java.sun.com/thread.jsp?forum=31&thread=499888
    and others, I copied (a second copy) the jar file to the directory where I am create my java objects.
    Then I unzipped it to that directory, creating three folders that hold the unzipped objects.
    I tried executing the program again. I get the messages at the top of this post.
    The Manifest file is in one of the three folders unzipped to my java work directory.
    In the second of the two above threads, jsalonen says:
    the problem can be solved by mentioning mysql.jar in the Class-Path attribute
    in the manifest of the jar file:
    In this "manifest" file, there are only three lines and I added a fourth and it looks like this
    (there are two, one in directory MySQL\META-INF and one in directory jwork\META-INF:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.1
    Created-By: 1.4.0_01-b03 (Sun Microsystems Inc.)
    Main-Class:jwork\ExecuteSQL
    How do I "mention" mysql.jar in the class path attribute?
    In the index.list file (in the directory with the manifest file, do I need to add anything to refer that "com.mysql.jdbc.driver" is the driver?
    Do I need index.list in MySQL\META-INF ?
    Thank you for your help. The program ExecuteSQL follows.
    * Copyright (c) 2000 David Flanagan. All rights reserved.
    * This code is from the book Java Examples in a Nutshell, 2nd Edition.
    * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.
    * You may study, use, and modify it for any non-commercial purpose.
    * You may distribute it non-commercially as long as you retain this notice.
    * For a commercial use license, or to purchase the book (recommended),
    * visit http://www.davidflanagan.com/javaexamples2.
    /** package com.davidflanagan.examples.sql; */
    import java.sql.*;
    import java.io.*;
    * A general-purpose SQL interpreter program.
    public class ExecuteSQL {
    public static void main(String[] args) {
    Connection conn = null; // Our JDBC connection to the database server
    try {
    String driver = "com.mysql.jdbc.driver", url = "jdbc:mysql://",
    user = "", password = "";
    // Parse all the command-line arguments
    for(int n = 0; n < args.length; n++) {
    if (args[n].equals("-d")) driver = args[++n];
    else if (args[n].equals("-u")) user = args[++n];
    else if (args[n].equals("-p")) password = args[++n];
    else if (url == null) url = args[n];
    else throw new IllegalArgumentException("Unknown argument.");
    // The only required argument is the database URL.
    if (url == null)
    throw new IllegalArgumentException("No database specified");
    // If the user specified the classname for the DB driver, load
    // that class dynamically. This gives the driver the opportunity
    // to register itself with the DriverManager.
    if (driver != null) Class.forName(driver);
    // Now open a connection the specified database, using the
    // user-specified username and password, if any. The driver
    // manager will try all of the DB drivers it knows about to try to
    // parse the URL and connect to the DB server.
    conn = DriverManager.getConnection(url, user, password);
    // Now create the statement object we'll use to talk to the DB
    Statement s = conn.createStatement();
    // Get a stream to read from the console
    BufferedReader in =
              new BufferedReader(new InputStreamReader(System.in));
    // Loop forever, reading the user's queries and executing them
    while(true) {
    System.out.print("sql> "); // prompt the user
    System.out.flush(); // make the prompt appear now.
    String sql = in.readLine(); // get a line of input from user
    // Quit when the user types "quit".
    if ((sql == null) || sql.equals("quit")) break;
    // Ignore blank lines
    if (sql.length() == 0) continue;
    // Now, execute the user's line of SQL and display results.
    try {
    // We don't know if this is a query or some kind of
    // update, so we use execute() instead of executeQuery()
    // or executeUpdate() If the return value is true, it was
    // a query, else an update.
    boolean status = s.execute(sql);
              // Some complex SQL queries can return more than one set
              // of results, so loop until there are no more results
    do {
    if (status) { // it was a query and returns a ResultSet
    ResultSet rs = s.getResultSet(); // Get results
    printResultsTable(rs, System.out); // Display them
    else {
    // If the SQL command that was executed was some
    // kind of update rather than a query, then it
    // doesn't return a ResultSet. Instead, we just
    // print the number of rows that were affected.
    int numUpdates = s.getUpdateCount();
    System.out.println("Ok. " + numUpdates +
                             " rows affected.");
    // Now go see if there are even more results, and
    // continue the results display loop if there are.
    status = s.getMoreResults();
    } while(status || s.getUpdateCount() != -1);
    // If a SQLException is thrown, display an error message.
    // Note that SQLExceptions can have a general message and a
    // DB-specific message returned by getSQLState()
    catch (SQLException e) {
    System.err.println("SQLException: " + e.getMessage()+ ":" +
                        e.getSQLState());
    // Each time through this loop, check to see if there were any
    // warnings. Note that there can be a whole chain of warnings.
    finally { // print out any warnings that occurred
              SQLWarning w;
    for(w=conn.getWarnings(); w != null; w=w.getNextWarning())
    System.err.println("WARNING: " + w.getMessage() +
                             ":" + w.getSQLState());
    // Handle exceptions that occur during argument parsing, database
    // connection setup, etc. For SQLExceptions, print the details.
    catch (Exception e) {
    System.err.println(e);
    if (e instanceof SQLException)
    System.err.println("SQL State: " +
                        ((SQLException)e).getSQLState());
    System.err.println("Usage: java ExecuteSQL [-d <driver>] " +
                   "[-u <user>] [-p <password>] <database URL>");
    // Be sure to always close the database connection when we exit,
    // whether we exit because the user types 'quit' or because of an
    // exception thrown while setting things up. Closing this connection
    // also implicitly closes any open statements and result sets
    // associated with it.
    finally {
    try { conn.close(); } catch (Exception e) {}
    * This method attempts to output the contents of a ResultSet in a
    * textual table. It relies on the ResultSetMetaData class, but a fair
    * bit of the code is simple string manipulation.
    static void printResultsTable(ResultSet rs, OutputStream output)
         throws SQLException
    // Set up the output stream
    PrintWriter out = new PrintWriter(output);
    // Get some "meta data" (column names, etc.) about the results
    ResultSetMetaData metadata = rs.getMetaData();
    // Variables to hold important data about the table to be displayed
    int numcols = metadata.getColumnCount(); // how many columns
    String[] labels = new String[numcols]; // the column labels
    int[] colwidths = new int[numcols]; // the width of each
    int[] colpos = new int[numcols]; // start position of each
    int linewidth; // total width of table
    // Figure out how wide the columns are, where each one begins,
    // how wide each row of the table will be, etc.
    linewidth = 1; // for the initial '|'.
    for(int i = 0; i < numcols; i++) {             // for each column
    colpos[i] = linewidth; // save its position
    labels[i] = metadata.getColumnLabel(i+1); // get its label
    // Get the column width. If the db doesn't report one, guess
    // 30 characters. Then check the length of the label, and use
    // it if it is larger than the column width
    int size = metadata.getColumnDisplaySize(i+1);
    if (size == -1) size = 30; // Some drivers return -1...
         if (size > 500) size = 30; // Don't allow unreasonable sizes
    int labelsize = labels.length();
    if (labelsize > size) size = labelsize;
    colwidths[i] = size + 1; // save the column the size
    linewidth += colwidths[i] + 2; // increment total size
    // Create a horizontal divider line we use in the table.
    // Also create a blank line that is the initial value of each
    // line of the table
    StringBuffer divider = new StringBuffer(linewidth);
    StringBuffer blankline = new StringBuffer(linewidth);
    for(int i = 0; i < linewidth; i++) {
    divider.insert(i, '-');
    blankline.insert(i, " ");
    // Put special marks in the divider line at the column positions
    for(int i=0; i<numcols; i++) divider.setCharAt(colpos[i]-1,'+');
    divider.setCharAt(linewidth-1, '+');
    // Begin the table output with a divider line
    out.println(divider);
    // The next line of the table contains the column labels.
    // Begin with a blank line, and put the column names and column
    // divider characters "|" into it. overwrite() is defined below.
    StringBuffer line = new StringBuffer(blankline.toString());
    line.setCharAt(0, '|');
    for(int i = 0; i < numcols; i++) {
    int pos = colpos[i] + 1 + (colwidths[i]-labels[i].length())/2;
    overwrite(line, pos, labels[i]);
    overwrite(line, colpos[i] + colwidths[i], " |");
    // Then output the line of column labels and another divider
    out.println(line);
    out.println(divider);
    // Now, output the table data. Loop through the ResultSet, using
    // the next() method to get the rows one at a time. Obtain the
    // value of each column with getObject(), and output it, much as
    // we did for the column labels above.
    while(rs.next()) {
    line = new StringBuffer(blankline.toString());
    line.setCharAt(0, '|');
    for(int i = 0; i < numcols; i++) {
    Object value = rs.getObject(i+1);
              if (value != null)
              overwrite(line, colpos[i] + 1, value.toString().trim());
    overwrite(line, colpos[i] + colwidths[i], " |");
    out.println(line);
    // Finally, end the table with one last divider line.
    out.println(divider);
    out.flush();
    /** This utility method is used when printing the table of results */
    static void overwrite(StringBuffer b, int pos, String s) {
    int slen = s.length(); // string length
    int blen = b.length(); // buffer length
    if (pos+slen > blen) slen = blen-pos; // does it fit?
    for(int i = 0; i < slen; i++) // copy string into buffer
    b.setCharAt(pos+i, s.charAt(i));

    Don't put those JARs in the lib/ext directory. Only language extensions (e.g., packages that start with "javax") belong in there.
    Learn how to set the CLASSPATH properly for starters:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
    You might want to look at the JDBC tutorial, too:
    http://java.sun.com/docs/books/tutorial/jdbc/
    Do one thing at a time. Get the program to work, then worry about packaging it into an executable JAR.

  • Problem with mySQL and Java

    I have a quite annoying problem.....!
    I use the getText() method to extract characters from a textfield pass them as a string and then using an INSERT store them in the database. When i am entering in the textfield something like the word - Java - everything is ok. When i am entering something like - Java Deceloper's Guide - the connection with the database fails.....!!! I have found that the problem is with the use of the apostrophe ( ' )!!
    Anyway to ovecome this???
    Thanx in advance!

    Thanx again!
    It worked!!!!
    By the way this was quite a stupid (i think) issue with JDBC, nevermind.
    Thanx

  • How to handle blob data with java and mysql and hibernate

    Dear all,
    I am using java 1.6 and mysql 5.5 and hibernate 3.0 . Some time i use blob data type . Earlier my project's data base was oracle 10g but now i am converting it to Mysql and now i am facing problem to save and fetch blob data to mysql database . Can anybody give me the source code for blob handling with java+Mysql+Hibernate
    now my code is :--
    ==================================================
    *.hbm.xml :--
    <property name="image" column="IMAGE" type="com.shrisure.server.usertype.BinaryBlobType" insert="true" update="true" lazy="false"/>
    ===================================================
    *.java :--
    package com.shrisure.server.usertype;
    import java.io.OutputStream;
    import java.io.Serializable;
    import java.sql.Blob;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Types;
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    import oracle.sql.BLOB;
    import org.hibernate.HibernateException;
    import org.hibernate.usertype.UserType;
    import org.jboss.resource.adapter.jdbc.WrappedConnection;
    import com.google.gwt.user.client.rpc.IsSerializable;
    public class BinaryBlobType implements UserType, java.io.Serializable, IsSerializable {
    private static final long serialVersionUID = 1111222233331231L;
    public int[] sqlTypes() {
    return new int[] { Types.BLOB };
    public Class returnedClass() {
    return byte[].class;
    public boolean equals(Object x, Object y) {
    return (x == y) || (x != null && y != null && java.util.Arrays.equals((byte[]) x, (byte[]) y));
    public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
    BLOB tempBlob = null;
    WrappedConnection wc = null;
    try {
    if (value != null) {
    Connection oracleConnection = st.getConnection();
    if (oracleConnection instanceof oracle.jdbc.driver.OracleConnection) {
    tempBlob = BLOB.createTemporary(oracleConnection, true, BLOB.DURATION_SESSION);
    if (oracleConnection instanceof org.jboss.resource.adapter.jdbc.WrappedConnection) {
    InitialContext ctx = new InitialContext();
    DataSource dataSource = (DataSource) ctx.lookup("java:/DefaultDS");
    Connection dsConn = dataSource.getConnection();
    wc = (WrappedConnection) dsConn;
    // with getUnderlying connection method , cast it to Oracle
    // Connection
    oracleConnection = wc.getUnderlyingConnection();
    tempBlob = BLOB.createTemporary(oracleConnection, true, BLOB.DURATION_SESSION);
    tempBlob.open(BLOB.MODE_READWRITE);
    OutputStream tempBlobWriter = tempBlob.getBinaryOutputStream();// setBinaryStream(1);
    tempBlobWriter.write((byte[]) value);
    tempBlobWriter.flush();
    tempBlobWriter.close();
    tempBlob.close();
    st.setBlob(index, tempBlob);
    } else {
    st.setBlob(index, BLOB.empty_lob());
    } catch (Exception exp) {
    if (tempBlob != null) {
    tempBlob.freeTemporary();
    exp.printStackTrace();
    st.setBlob(index, BLOB.empty_lob());
    // throw new RuntimeException();
    } finally {
    if (wc != null) {
    wc.close();
    public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
    final Blob blob = rs.getBlob(names[0]);
    return blob != null ? blob.getBytes(1, (int) blob.length()) : null;
    public Object deepCopy(Object value) {
    if (value == null)
    return null;
    byte[] bytes = (byte[]) value;
    byte[] result = new byte[bytes.length];
    System.arraycopy(bytes, 0, result, 0, bytes.length);
    return result;
    public boolean isMutable() {
    return true;
    public Object assemble(Serializable arg0, Object arg1) throws HibernateException {
    return assemble(arg0, arg1);
    public Serializable disassemble(Object arg0) throws HibernateException {
    return disassemble(arg0);
    public int hashCode(Object arg0) throws HibernateException {
    return hashCode();
    public Object replace(Object arg0, Object arg1, Object arg2) throws HibernateException {
    return replace(arg0, arg1, arg2);
    =================================================================
    can anyone give me the source code for this BinaryBlobType.java according to mysql blob handling ..

    Moderator action: crosspost deleted.

  • Issue in bringing up CRS on ATG 10.1.1 with MySQL and Weblogic 10.3

    Hello,
    I am trying to bring up Commerce Reference Store as part of my evaluation using MySQL (bundled with ATG) and WebLogic 10.3.
    I followed the ATG Documentation on CRS with WebLogic and MySQL and I could not proceed because of the below error log. I keep getting error in OnlineCreateServerInstanceTask of CIM. I believe it should be some configuration problem, but could not think of any.
    As part of the installation, I use C:\jdk1.6.0_25. I verified my weblogic server is up through the admin console. I started MySQL before running the eval batch. Apart from starting MySQL server, I did not make any datasource/database configuration changes for ATG. I have not run any other scripts to configure MySQL too.
    Please guide me to resolve the problem.
    C:\ATG\ATG10.1.1\CommerceReferenceStore\Store\eval>configureEval.bat
    Do you wish to run the CRS evaluation installation? [Y/N]: y
    Do you wish to use an existing database for the CRS evaluation? [Y/N]: n
    The CRS evaluation install will attempt to create the database. Press [Return] t
    o continue or any other key to quit:
    Enter mysql database connection details
    Enter user name: admin
    Enter user password: admin
    Enter database name: crsprod
    Enter 'root' user password:
    Creating database...
    Finished database creation
    Enter weblogic admin server URL: http://localhost:7001
    Enter weblogic admin server username: weblogic
    Enter weblogic admin server password: weblogic123
    Buildfile: C:\ATG\ATG10.1.1\CommerceReferenceStore\Store\eval\evalbuild.xml
    all:
    [copy] Copying 1 file to C:\ATG\ATG10.1.1\CommerceReferenceStore\Store\eval
    [delete] Deleting: C:\ATG\ATG10.1.1\CommerceReferenceStore\Store\eval\cimOut.
    cim.tmp
    BUILD SUCCESSFUL
    Total time: 0 seconds
    Application Server: weblogic
    The following installed ATG components are being used to launch:
    ATGPlatform version 10.1.1 installed at C:\ATG\ATG10.1.1
    Created "C:\ATG\ATG10.1.1\home\CIM\startDynamo.jar" in 15,273ms.
    Nucleus running
    atg.cim.productconfig.productselector.ProductSelectionContextTask starting...
    (Searching for products... done.)
    atg.cim.productconfig.productselector.ProductSelectionContextTask finished.
    atg.cim.productconfig.appserver.AppServerSelectTask starting...
    atg.cim.productconfig.appserver.AppServerSelectTask finished.
    atg.cim.productconfig.appserver.AppServerPathTask starting...
    atg.cim.productconfig.appserver.AppServerPathTask finished.
    atg.cim.productconfig.appserver.DomainPathTask starting...
    atg.cim.productconfig.appserver.DomainPathTask finished.
    atg.cim.productconfig.appserver.UrlTask starting...
    atg.cim.productconfig.appserver.UrlTask finished.
    atg.cim.productconfig.appserver.UsernameTask starting...
    atg.cim.productconfig.appserver.UsernameTask finished.
    atg.cim.productconfig.appserver.PasswordTask starting...
    atg.cim.productconfig.appserver.PasswordTask finished.
    atg.cim.productconfig.appserver.AppServerSelectionPersistenceTask starting...
    atg.cim.productconfig.appserver.AppServerSelectionPersistenceTask finished.
    atg.cim.database.CreateSchemaTask starting...
    atg.cim.database.CreateSchemaTask finished.
    atg.cim.database.ImportDataTask starting...
    Combining template tasks...Success
    Importing (1 of 1) /CIM/tmp/import/nonswitchingCore-import1.xml:
    /CommerceReferenceStore/Store/Storefront/data/pricelists.xml to /atg/commerce/pr
    icing/priceLists/PriceLists
    /CommerceReferenceStore/Store/Storefront/data/stores.xml to /atg/store/stores/St
    oreRepository
    /CommerceReferenceStore/Store/Storefront/data/catalog-i18n.xml to /atg/commerce/
    catalog/ProductCatalog
    /CommerceReferenceStore/Store/Storefront/data/pricelists-i18n.xml to /atg/commer
    ce/pricing/priceLists/PriceLists
    /CommerceReferenceStore/Store/Storefront/data/sites.xml to /atg/multisite/SiteRe
    pository
    /CommerceReferenceStore/Store/Storefront/data/sites-i18n.xml to /atg/multisite/S
    iteRepository
    /CommerceReferenceStore/Store/Storefront/data/promos-i18n.xml to /atg/commerce/c
    atalog/ProductCatalog
    /CommerceReferenceStore/Store/Storefront/data/seotags-i18n.xml to /atg/seo/SEORe
    pository
    /CommerceReferenceStore/Store/Storefront/data/wishlists.xml to /atg/commerce/gif
    ts/Giftlists
    /CommerceReferenceStore/Store/Storefront/data/inventory.xml to /atg/commerce/inv
    entory/InventoryRepository
    /CommerceReferenceStore/Store/Storefront/data/users.xml to /atg/userprofiling/Pr
    ofileAdapterRepository
    /CommerceReferenceStore/Store/Storefront/data/orders.xml to /atg/commerce/order/
    OrderRepository
    /CommerceReferenceStore/Store/Storefront/data/orders-i18n.xml to /atg/commerce/o
    rder/OrderRepository
    /CommerceReferenceStore/Store/Storefront/data/storetext-i18n.xml to /atg/store/s
    tores/StoreRepository
    /CommerceReferenceStore/Store/Storefront/data/claimable-i18n.xml to /atg/commerc
    e/claimable/ClaimableRepository
    ... > Success
    All Imports Completed Successfully
    atg.cim.database.ImportDataTask finished.
    atg.cim.worker.common.PropertyFileClearPersistanceTask starting...
    atg.cim.worker.common.PropertyFileClearPersistanceTask finished.
    atg.cim.productconfig.serverinstance.ServerInstanceNameTask starting...
    atg.cim.productconfig.serverinstance.ServerInstanceNameTask finished.
    atg.cim.productconfig.serverinstance.PortBindingsSelectTask starting...
    atg.cim.productconfig.serverinstance.PortBindingsSelectTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.worker.common.MapPropertyFileCreatorTask starting...
    atg.cim.worker.common.MapPropertyFileCreatorTask finished.
    atg.cim.productconfig.serverinstance.MakeServerInstanceFromPatternTask starting.
    atg.cim.productconfig.serverinstance.MakeServerInstanceFromPatternTask finished.
    atg.cim.productconfig.appassembly.EarFileNameTask starting...
    atg.cim.productconfig.appassembly.EarFileNameTask finished.
    atg.cim.productconfig.deploy.weblogic.OnlineCreateServerInstanceTask starting...
    Error Executing Batch File
    atg.cim.worker.TaskException: Error deploying to weblogic
    atg.cim.worker.TaskException: Error exececuting batch file
    at atg.cim.flow.CimFlowCreator.startHeadlessCimFlow(CimFlowCreator.java:
    130)
    at atg.cim.Launcher.startCimFlow(Launcher.java:278)
    at atg.cim.Launcher.main(Launcher.java:99)
    Caused by: atg.cim.worker.TaskException: Error deploying to weblogic
    at atg.cim.worker.Task.handleException(Task.java:72)
    at atg.cim.productconfig.deploy.weblogic.OnlineCreateServerInstanceTask.
    execute(OnlineCreateServerInstanceTask.java:159)
    at atg.cim.headless.HeadlessExecutorImpl.executeTasks(HeadlessExecutorIm
    pl.java:150)
    at atg.cim.headless.HeadlessExecutorImpl.populateAndExecuteHeadlessTasks
    (HeadlessExecutorImpl.java:140)
    at atg.cim.batch.BatchChooserExecutor.populateAndExecuteHeadlessTasks(Ba
    tchChooserExecutor.java:169)
    at atg.cim.flow.CimFlow.headlessFlow(CimFlow.java:116)
    at atg.cim.flow.CimFlowCreator.startHeadlessCimFlow(CimFlowCreator.java:
    120)
    ... 2 more
    Caused by: C:\ATG\ATG10.1.1\CIM\plugins\Base\ant\cim-ant.xml:348: The following
    error occurred while executing this line:
    C:\ATG\ATG10.1.1\CIM\plugins\Base\ant\cim-ant.xml:254: The following error occur
    red while executing this line:
    C:\ATG\ATG10.1.1\CIM\plugins\Base\ant\cim-ant.xml:214: exec returned: 1
    at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(Projec
    tHelper.java:541)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.jav
    a:394)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
    a:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    at atg.cim.task.ant.utility.AntExecutionWrapper.executeAntTarget(AntExec
    utionWrapper.java:167)
    at atg.cim.worker.AntTask.executeAntTarget(AntTask.java:115)
    at atg.cim.productconfig.deploy.weblogic.OnlineCreateServerInstanceTask.
    execute(OnlineCreateServerInstanceTask.java:155)
    ... 7 more
    Caused by: C:\ATG\ATG10.1.1\CIM\plugins\Base\ant\cim-ant.xml:254: The following
    error occurred while executing this line:
    C:\ATG\ATG10.1.1\CIM\plugins\Base\ant\cim-ant.xml:214: exec returned: 1
    at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(Projec
    tHelper.java:541)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.jav
    a:394)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
    a:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
    a:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.jav
    a:391)
    ... 20 more
    Caused by: C:\ATG\ATG10.1.1\CIM\plugins\Base\ant\cim-ant.xml:214: exec returned:
    1
    at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:636)
    at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:662)
    at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:487)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
    a:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
    a:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.jav
    a:391)
    ... 34 more
    Nucleus shutting down
    Nucleus shutdown complete
    Thanks.

    This error is resolved after following the logs in C:\ATG\ATG10.1.1\CIM\log\cim.log. The root cause is I used http as protocol instead of t3 while specifying weblogic admin url.
    http://localhost:7001 instead of t3://localhost:7001
    Thanks.

  • Using mysql-connector-java-5.0.5 from oracle's java procedure.

    I need to write the java procedure in Oracle, which will get connection to mySQL server and put some data into it. I am using official mysql-connector-java-5.0.5 driver for this job. Java class for this job work well outside the Oracle. The problem is:
    When I try to import jar file of mysql connectior it fail son resolving inside the Oracle db. How can I get access to mysql from Oracle?

    Thanks for this quick reply!!
    --When adding a connection and clicking 'Test' in the end of the wizard or when right-click on the connection and click 'connect'.
    Also, I've just noticed this: when I start IDE using jdev.exe I'm getting:
    java.lang.NullPointerException at oracle.jdevimpl.cm.dt.DatabaseAddin._registerIDEObjects(DatabaseAddin.java:353)
    at oracle.jdevimpl.cm.dt.DatabaseAddin.initialize(DatabaseAddin.java:155
    at oracle.ideimpl.extension.AddinManagerImpl.initializeAddin(AddinManage
    rImpl.java:425)
    at oracle.ideimpl.extension.AddinManagerImpl.initializeAddins(AddinManag
    erImpl.java:240)
    at oracle.ideimpl.extension.AddinManagerImpl.initProductAndUserAddins(Ad
    dinManagerImpl.java:154)
    at oracle.ide.IdeCore.initProductAndUserAddins(IdeCore.java:1431)
    at oracle.ide.IdeCore.startupImpl(IdeCore.java:1196)
    at oracle.ide.Ide.startup(Ide.java:674)
    at oracle.ideimpl.Main.start(Main.java:49)
    at oracle.ideimpl.Main.main(Main.java:25)
    Does not look right to me.
    I've never tried to add a DB connection under this IDE installation earlier.
    Just yeasterday I've created a project with some DB related (mySQL and Hibernate) libraries, although it compiled fine.

  • MySQL and JDBC Classpath errors

    I am new to Java and installed MySql and also installed mysql-connectorJ driver. I can compile the code below, but when I go to run it, I get "Exception in thread "main" java.lang.NoClassDefFoundError: JDBCDemo/class" error. I can't figure out what I am doing wrong.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class JDBCDemo {
         public static void main(String[] args) {
              try{  
    Class.forName("com.mysql.jdbc.Driver");
              catch (Exception e)
                   e.printStackTrace();
    I have a the following environment variable called MySQL_Driver located at "C:\Program Files\Java\jdk1.5.0_06\lib".
    Path = "%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared;%JAVA_HOME%;%JAVA_HOME%\lib;%JAVA_VM%\bin;%JAVA_VM%\lib;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\QuickTime\QTSystem\;%MySQL_Driver%"

    What is your CLASSPATH set to as you need to make sure that the driver is in the path as well as the directory/jar where the JDBCDemo app lives.
    Try explictly specifying everything via the -classpath option on your java command line

  • Java\jdk1.6.0_02\jre\lib\ext\mysql-connector-java-5.1.16-bin.jar was unexp

    Hello, please i am new to Jdeveloper and weblogic servers and i developed an application using jdeveloper and when i try to run the application it brings up this error message
    "*** Using HTTP port 7101 ***
    *** Using SSL port 7102 ***
    C:\Users\Lucky\AppData\Roaming\JDeveloper\system11.1.2.3.39.62.76.1\DefaultDomain\bin\startWebLogic.cmd
    [waiting for the server to complete its initialization...]
    \Java\jdk1.6.0_02\jre\lib\ext\mysql-connector-java-5.1.16-bin.jar was unexpected at this time.
    Process exited."
    I tried deleting the jdk1.6.6.0_02 and tried it again but it still did not run, I also uninstalled the JDeveloper and weblogic server and reinstalled them but the error message still pops up. Please i need help to fix this.
    Thanks.
    Edited by: Chinedu on Feb 21, 2013 8:48 AM

    Andrew,
    Thanks for the lightning response... but the problem has been solved.
    I rebooted again, and installed again (didn't download again because the filesize checked out) and now it works fine, and I'm none the wiser as to the root cause of the problem, except that rt.jar has magically appeared:
    C:\Users\Administrator>dir "C:\Program Files\Java\jre6\lib\*.jar"
    Volume in drive C has no label.
    Volume Serial Number is 00AC-1BC7
    Directory of C:\Program Files\Java\jre6\lib
    08/11/2009  06:38 PM         6,685,813 charsets.jar
    08/11/2009  06:38 PM         2,989,538 deploy.jar
    08/11/2009  06:38 PM           716,841 javaws.jar
    08/11/2009  06:38 PM            88,256 jce.jar
    08/11/2009  06:38 PM           558,189 jsse.jar
    08/11/2009  06:38 PM               382 management-agent.jar
    08/11/2009  06:38 PM         1,704,664 plugin.jar
    08/11/2009  06:38 PM         1,115,985 resources.jar
    08/11/2009  06:38 PM        44,295,255 rt.jar                             <<<<<<<<<<<<<<<<<<
                   9 File(s)     58,154,923 bytes
                   0 Dir(s)  115,454,173,184 bytes freeSOOOO... I presume that the installer failed on rt.jar, probably because something (something in my start-up, I suppose) was using the JRE while the instal was running... but I didn't do anything different the second time (to the best of my knowledge).
    Thanks anyways... My hair (what's left of it) greatly appreciates your time.
    Cheers. Keith.

  • Mysql and Weblogic 10.3.5

    I was working fine with mysql on weblogic 10.3.2.
    But with weblogic 10.3.5 it's getting problem.
    There are two jars in wlserver_10.3\server\ext\jdbc\mysql\
    1)mysql-connector-java-commercial-5.0.3-bin.jar
    2)mysql-connector-java-commercial-5.1.14-bin.jar
    When I put the first in the weblogic classpath I get the following message when my application is starting
    <13/03/2012 15h24min58s BRT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
    java.lang.NoClassDefFoundError: com/mysql/jdbc/DatabaseMetaData
    at weblogic.jdbc.wrapper.DatabaseMetaData_com_mysql_jdbc_DatabaseMetaData.getDatabaseProductName(Unknown Source)
    at org.apache.openjpa.lib.jdbc.DelegatingDatabaseMetaData.getDatabaseProductName(DelegatingDatabaseMetaData.java:137)
    at org.apache.openjpa.jdbc.sql.DBDictionaryFactory.newDBDictionary(DBDictionaryFactory.java:93)
    at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:554)
    at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1250)
    Truncated. see log file for complete stacktrace
    And when I choose the second jar I get another NoClassDefFoundError:
    Caused By: java.lang.NoClassDefFoundError: com/mysql/jdbc/MySQLConnection
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:630)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:614)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:343)
    I have no problem to configure the mysql datasource in weblogic console.
    The problem happens just to start my application.
    Can anybody help?
    Thanks. Mauro.

    Can you check if these classes are contained in the jars or not?
    You can also put the jar file that was working for you on WebLogic 10.3.2 in the classpath of WebLogic 10.3.5

  • MySql and Tomcat 5.5

    I have read several threads, and others are having this problem but the resolutions do not seem to be posted or are different than what I am having. Hopefully someone can help me figure out...
    Cannot create JDBC driver of class '' for connect URL 'null'
    I verified that my url was correct here...
    http://dev.mysql.com/doc/connector/j/en/cj-driver-classname.html
    Here is my server.xml snippet
    <GlobalNamingResources>
    <Resource name="jdbc/mtshr" auth="Container"
    type="javax.sql.DataSource" username="xxxx" password="xxxx"
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/mtshr?autoReconnect=true"
    maxActive="8" maxIdle="4"/>
    </GlobalNamingResources>
    in my WEB-INF/web.xml
    <resource-ref>
    <description>
    HRDB Deployment
    </description>
    <res-ref-name>
    jdbc/mtshr
    </res-ref-name>
    <res-type>
    javax.sql.DataSource
    </res-type>
    <res-auth>
    Container
    </res-auth>
    </resource-ref>
    I have tried moving the mysql-connector-java-3.1.7-bin.jar to both common/lib and WEB-INF/lib
    My code to connect is...
    java.sql.Connection Conn = null;
    javax.sql.DataSource ds = null;
    java.sql.Statement Stmt = null;
    java.sql.ResultSet rs = null;
    javax.naming.InitialContext ctx = new javax.naming.InitialContext();
    javax.naming.Context envctx = (javax.naming.Context) ctx.lookup("java:comp/env");
    ds = (javax.sql.DataSource) envctx.lookup("jdbc/mtshr");
    Conn = ds.getConnection();
    Stmt = Conn.createStatement();
    (delete these last two statements and no errors)
    Any help is GREATLY appreciated. I had everything running in TC 3.2.3 and 4.1 I thought it would be a good idea and exercise to revisit my code and get some experience with j2se 5.0 and TC 5.5
    Not promising if I can't even get past the setup :) Thanks again!

    SO...
    I created a META-INF folder in my app, and then created a file called context.xml which contained the same code as I had in my server.xml file.
    In the documentation http://localhost:8080/tomcat-docs/jndi-datasource-examples-howto.html#Common%20Problems
    it says that you can use global naming instead of context. Didn't work with global naming but it did work with context. No idea why, just know that it did.

  • Oracle.exe and java.exe are running my CPU 100% under XP Prof SP3

    11gR1
    oracle.exe and java.exe are running 100% CPU
    I have increased virtual memory to 4 gig
    I have defragmented the drive.
    I checked the drive for errors.
    I am searching the whole drive for viruses
    I do not have the problem with Redhat Fedora 12 running 11gR1
    I have 1 gig of RAM but cannot install release 2 because the installer expects
    1 gig + 1

    ooops!!! left that off...sorry
    XP Prof SP3 32 bit..*.no problem with Redhat Fedora 12 running MySQL and 11gR1*
    1 gig RAM Dell precision W/S 1.5 Gig rate 74 GiG SCSI HD 15000 RPM
    Don't pass out but I am also running MySQL server 5.1.41 and MS SQL Server Express 2008.
    Lucky it didn't catch fire
    I installed XP prof months ago but this CPU domination occurred only starting last night!
    However slow everything works in 11gR1
    sqlplus myname/password and then select rows from table
    sqldeveloper
    PHP web sites
    I've had plenty of trouble with Java running slow and hogging memory!
    Edited by: landonmkelsey on May 2, 2010 12:21 PM
    Edited by: landonmkelsey on May 2, 2010 12:24 PM
    Let me guess...stop services for MySQL and MS SQL Server and see what happens!
    Edited by: landonmkelsey on May 2, 2010 12:26 PM

  • Need help setting up JDBC with mySQL and Netbeans

    I've successfully got mySQL up and running and created a few simple test databases. I've been following the instructions on this website (http://www.stardeveloper.com/articles/display.html?article=2003090401&page=1 ) to get JDBC working but have had little luck.
    I've downloaded JDBC from mySQL website, extracted the mysql-connector-java-3.1.13-bin.jar file and changed the class path to :
    C:\Program Files\Java\jre1.5.0_06\lib\ext\mysql-connector-java-3.1.13-bin
    which is where I placed the .jar file.
    I then used the following code provided on stardeveloper.com to test a connection with the test database.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class JdbcExample2 {
      public static void main(String args[]) {
        Connection con = null;
        try {
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          con = DriverManager.getConnection("jdbc:mysql:///test",
            "root", "secret");
          if(!con.isClosed())
            System.out.println("Successfully connected to " +
              "MySQL server using TCP/IP...");
        } catch(Exception e) {
          System.err.println("Exception: " + e.getMessage());
        } finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
    }It compiles but when run I get the error message :
    java.lang.NoClassDefFoundError: testdatabase/JdbcExample2
    Exception in thread "main"I assume this means that my classpath isn't setup correctly but I have no idea what's up and how to correct it.
    Can someone PLEASE tell me how to setup jdbc and what I've done wrong.
    Thanks in advance :)

    Thanks for your reply. I've made some progress but I'm still having problems.
    In mySQL I created a new user called uraknai with password n0121429 and granted them access to a test database I created called pet.
    Then, in netbeans, I clicked the Runtime tab, clicked Databases and rightclicked Drivers and clicked Add Driver. I then added the driver mysql-connector-java-3.1.13-bin.jar. I then right clicked the newly added driver and selected the connect using option. I filled in the appropriate boxes clicked ok and it connected successfully.
    Then, under the project tab, I right clicked the project name, clicked properties then clicked Libraries and added the .jar file mysql-connector-java-3.1.13-bin.jar
    I then ran the following code to test the connection to the database:
    import java.sql.*;
    public class ConnectionTest {
        public ConnectionTest() {
        public static void main(String[] args)
            System.out.println("BEGIN CONNECTION TEST");
            Connection conn = null;
            try
                   String userName = "uraknai";
                   String password = "n0121429";
                   String url = "jdbc:mysql://localhost/pet";
                   Class.forName ("com.mysql.jdbc.Driver").newInstance ();
                   conn = DriverManager.getConnection (url, userName, password);
                   System.out.println ("Database connection established");
             catch (Exception e)
                   System.err.println ("Cannot connect to database server");
             finally
                   if (conn != null)
                       try
                           conn.close ();
                           System.out.println ("Database connection terminated");
                       catch (Exception e) { /* ignore close errors */ }
    }and get the message:
    java.lang.NoClassDefFoundError: math/ConnectionTest
    Exception in thread "main"
    Java Result: 1when I run the code.
    Can someone explin what I've done wrong and how to fix the problem.
    Cheers.

  • Trouble creating a database in MySQL using java

    Hi all,
    I am trying to create a program that connects to MySQL and can create databases, tables etc. I can connect to MySQL using the program but I cannot create a database (however if i create the database with the command line i can create tables in the database).
    When I try to create a database i get the error
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'persondatabase'Here is the code:
    import java.sql.*;
    class Connect {
    public Connect() {
    public Connection connectToMySQL(String database_name) {
      Connection con = null;
      try {
       Class.forName("com.mysql.jdbc.Driver").newInstance();
       con = DriverManager.getConnection("jdbc:mysql:///persondatabase", "", "");
      catch(ClassNotFoundException e) { System.out.println(e); }
      catch(InstantiationException e) { System.out.println(e); }
      catch(SQLException e) { System.out.println(e); }
      finally {
       return con;
    public void createDatabase(String database_name) {
      Connection con = null;
      Statement stmt = null;
      try {
       con = connectToMySQL(null);  //connect to mysql but not to any one databases
       con.setAutoCommit(false);
       if(!con.isClosed())
        System.out.println("Connected to MySQL. Creating the Database " + database_name);
       String str = "CREATE DATABASE " + database_name;
       stmt = con.createStatement();
       stmt.executeUpdate(str);
       con.commit();
      catch (Exception e2) { }
      finally {
       try {
        stmt.close();
        con.close();
       }catch (Exception e3) { }
    public void createPersonDetailsTable(String database_name, String table_name) {
      Connection con = null;
      Statement stmt = null;
      try {
       con = connectToMySQL(database_name);
       con.setAutoCommit(false);
       if(!con.isClosed())
        System.out.println("Connected to " + database_name + " creating the table " + table_name);
       String str = "CREATE TABLE " + table_name + "(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(25), last_name VARCHAR(25), address VARCHAR(40), suburb VARCHAR(20), state VARCHAR(3), post_code INT(1), contact_number INT(10), email_address VARCHAR(40));";
       stmt = con.createStatement();
       stmt.executeUpdate(str);
       con.commit();
      catch (Exception e2) { System.out.println(e2); }
      finally {
       try {
        stmt.close();
        con.close();
       }catch (Exception e3) {  }
    }I am wondering if anyone can see where im going wrong? I am currently connecting with an anon account to MySQL.
    Here is the program I am using to test the above:
    class ConnectionTester {
    public ConnectionTester() {
      Connect s = new Connect();
      s.createDatabase("PersonDatabase");  //this throws the error
      //s.createPersonDetailsTable("PersonDatabase", "PersonDetails");
    public static void main(String[] arg) {
      ConnectionTester start = new ConnectionTester();
    }

    you should rethink whether you need to create a database using java. personally i think it's a bad idea. your database should exist and the schema should be ready to go when your app starts. why do you think you need to create one?
    %

  • Using MySQL with Java

    Hi, I am writing a database program, and I decided I should try and use MySQL since many people have told me it is the best way to make a database. Does the java version that Sun provide come with the api to create mysql databases?
    Also, I would like to know of a good tutorial that teaches MySQL with java.

    Hi, I am writing a database program, and I decided I
    should try and use MySQL since many people have told
    me it is the best way to make a database. Does the
    java version that Sun provide come with the api to
    create mysql databases?
    You are more than a bit confused so please stop here until you understand the following.
    JDBC is the API for communicating with relational databases in Java. It is not a database in and of itself but it can communicate with any database that provides JDBC API access in the form of a JDBC driver.
    Also, I would like to know of a good tutorial that
    teaches MySQL with java.The Sun tutorial on JDBC may be found here http://java.sun.com/docs/books/tutorial/jdbc/index.html
    Your using (or not) MySQL is not relevent on this forum and any questions you have regarding MySQL (with the exception of one) are beyond the scope of this forum.
    The exception is "Is there a JDBC driver for MySQL and how do I use it". The answer to that question is yes and see this http://www.mysql.com/products/connector/j/

  • MySql with java

    hi all,
    I got one problem with MySql ..
    I am using MySql for database but I got problem while start the
    MySql that is Not found the Driver...
    i think the problem is path I have not set the path for MySql
    So please tell me if anyone knows how to set the path ....
    Error message in MySql is > Driver 3.51 Not Found
    I Installed the MySQl in the D\mysql and start the mysql
    So please tell me ...
    thanks.........

    does this question have anything to do with Java or is it what it appears to be... a problem with mysql. if it is you are on the wrong site doncha think... try the mysql website http://www.mysql.com/

Maybe you are looking for