Help on mysql driver

Hi i have downloaded mySQL for windows XP and it works fine. I am having problems with the driver though. In setting the class path in control pane, for name i typed "name=classpath" and for value i typed "value=c:\mysql\drivers\mysql.jar". But when i try and run some code its says "Driver not found" the code is fine coz i have used it on a machine with windows 98 and it works fine. Not only does it not work but my Java classes do not run till i delete the path setting for mySQL. Can anyone help me with this. Thanx

thanx guys.....Sudha, in the name field i type classpath and in the value field i type c:\mysql\drivers\mysql.jar. But when i do that my java classes dont even run It says "java is not recognised as an internal or external command"
I even set the classpath in autoexec but when i run a program is says "Driver not Loaded"
The program works coz i have checked it on a machine running windows 98..
Any suggestions please

Similar Messages

  • URGENT - org.gjt.mysql.driver Issues... Please help...

    import java.sql.*;
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class receiving extends Applet implements ItemListener, ActionListener
    Connection conDatabase;//door to the database
    Statement cmdDatabase;//messenger
    ResultSet rsDatabase;//bucket
    private String dbURL = "jdbc:mysql://web6.duc.auburn.edu/?user=gunthms&password=tigers05";
    boolean blnSuccessfulOpen = false;
    Choice Order_No = new Choice();
    TextField txtOrder_No = new TextField(6);
    TextField txtCompany = new TextField(20);
    TextField txtLocation = new TextField(20);
    TextField txtDate_Shipped = new TextField(10);
    TextField txtBlack_Poly = new TextField(8);
    TextField txtBlue_Poly = new TextField(8);
    TextField txtBrass1 = new TextField(8);
    TextField txtBrass2 = new TextField(8);
    TextField txtTransaction_No = new TextField(8);
    TextField txtTracking_No = new TextField(18);
    Button btnAdd = new Button("Add");
    Button btnEdit = new Button("Save");
    Button btnCancel = new Button("Cancel");
    Button btnDelete = new Button("Delete");
    Button btnNext = new Button(" > ");
    Button btnLast = new Button(" >>> ");
    Button btnPrevious = new Button(" < ");
    Button btnFirst = new Button(" <<< ");
    public void init()
    //Set up panel and load database
    LoadDatabase();
    if (blnSuccessfulOpen)
    Order_No.insert("Select an Order",0);
    add(Order_No);
    add(new Label(" "));
    Order_No.addItemListener(this);
    add(new Label("Order No"));
    add(txtOrder_No);
    add(new Label("Company"));
    add(txtCompany);
    add(new Label("Location"));
    add(txtLocation);
    add(new Label(" "));
    add(new Label("Date Shipped"));
    add(txtDate_Shipped);
    add(new Label(" "));
    add(new Label("Black Poly (sqft)"));
    add(txtBlack_Poly);
    add(new Label("Blue Poly (sqft)"));
    add(txtBlue_Poly);
    add(new Label("Brass 1inch (pcs)"));
    add(txtBrass1);
    add(new Label("Brass 2inch (pcs)"));
    add(txtBrass2);
    add(new Label(" "));
    add(new Label("Transaction No"));
    add(txtTransaction_No);
    add(new Label(" "));
    add(new Label("Tracking No"));
    add(txtTracking_No);
    setTextToNotEditable();
    add(new Label(" "));
    add(btnAdd);
    btnAdd.addActionListener(this);
    add(btnEdit);
    btnEdit.addActionListener(this);
    add(btnDelete);
    btnDelete.addActionListener(this);
    add(btnCancel);
    btnCancel.addActionListener(this);
    btnCancel.setEnabled(false);
    //Navigate Buttons
    add(btnFirst);
    btnFirst.addActionListener(this);
    add(btnPrevious);
    btnPrevious.addActionListener(this);
    add(btnNext);
    btnNext.addActionListener(this);
    add(btnLast);
    btnLast.addActionListener(this);
    else
    System.err.println("Unable to populate fields");
    public void LoadDatabase()
    try
    //Load MySQL drivers
    Class.forName("org.gjt.mm.mysql.Driver");
    catch ( java.lang.ClassNotFoundException e )
    System.err.println("MySQL ORG Package Driver not found ...");
    System.err.println(e.getMessage());
    /* try
    //Load MySQL drivers
    Class.forName("com.mysql.jdbc.Driver");
    catch ( java.lang.ClassNotFoundException e )
    System.err.println("MySQL COM Package Driver not found ...");
    System.err.println(e.getMessage());
    try
    //Connect to the database
    conDatabase = DriverManager.getConnection(dbURL);
    catch(SQLException error)
    System.err.println("Unable to Connect to Database");
    try
    Statement cmdDatabase = conDatabase.createStatement();
    //Create the ResultSet
    rsDatabase = cmdDatabase.executeQuery("Select * from gunthmsjv.RECEIVING;");
    loadNumbers(rsDatabase);
    blnSuccessfulOpen = true;
    catch(SQLException error)
    System.err.println("Error in recordset");
    public void loadNumbers(ResultSet rsDatabase)
    //Fill last name list box
    try
    while(rsDatabase.next())
    Order_No.add(rsDatabase.getString("Order_No"));
    catch (SQLException error)
    System.err.println("Error in Display Record");
    public void itemStateChanged(ItemEvent event)
    //Retrieve and display the selected record
    String strOrder_No = Order_No.getSelectedItem();
    showStatus(""); //Delete instructions
    try
    Statement cmdDatabase = conDatabase.createStatement();
    rsDatabase = cmdDatabase.executeQuery(
    "Select * from gunthmsjv.RECEIVING where Order_No = '" + strOrder_No + "';");
    txtOrder_No.setText(strOrder_No);
    displayRecord(rsDatabase);
    setTextToEditable();
    catch(SQLException error)
    showStatus("Error in recordset");
    public void displayRecord(ResultSet rsDatabase)
    //Display the current record
    try
    if(rsDatabase.next())
    txtOrder_No.setText(rsDatabase.getString("Order_No"));
    txtCompany.setText(rsDatabase.getString("Company"));
    txtLocation.setText(rsDatabase.getString("Location"));
    txtDate_Shipped.setText(rsDatabase.getString("Date_Shipped"));
    txtBlack_Poly.setText(rsDatabase.getString("Black_Poly"));
    txtBlue_Poly.setText(rsDatabase.getString("Blue_Poly"));
    txtBrass1.setText(rsDatabase.getString("Brass1"));
    txtBrass2.setText(rsDatabase.getString("Brass2"));
    txtTransaction_No.setText(rsDatabase.getString("Transaction_No"));
    txtTracking_No.setText(rsDatabase.getString("Tracking_No"));
    showStatus("");
    else
    showStatus("Record not found");
    ClearTextFields();
    catch (SQLException error)
    showStatus("Error in display record");
    public void actionPerformed(ActionEvent event)
    //Test the command buttons
    Object objSource = event.getSource();
    if(objSource == btnAdd && event.getActionCommand() == "Add")
    Add();
    else if (objSource == btnAdd)
    Save();
    else if(objSource == btnEdit)
    Edit();
    else if(objSource == btnDelete)
    Delete();
    else if(objSource == btnCancel)
    Cancel();
    else if(objSource == btnFirst)
    firstRecord();
    else if(objSource == btnNext)
    nextRecord();
    else if(objSource == btnPrevious)
    previousRecord();
    else if(objSource == btnLast)
    lastRecord();
    public void setTextToNotEditable()
    //Lock the text fields
    txtOrder_No.setEditable(false);
    txtCompany.setEditable(false);
    txtLocation.setEditable(false);
    txtDate_Shipped.setEditable(false);
    txtBlack_Poly.setEditable(false);
    txtBlue_Poly.setEditable(false);
    txtBrass1.setEditable(false);
    txtBrass2.setEditable(false);
    txtTransaction_No.setEditable(false);
    txtTracking_No.setEditable(false);
    public void setTextToEditable()
    //Unlock the text fields
    txtOrder_No.setEditable(true);
    txtCompany.setEditable(true);
    txtLocation.setEditable(true);
    txtDate_Shipped.setEditable(true);
    txtBlack_Poly.setEditable(true);
    txtBlue_Poly.setEditable(true);
    txtBrass1.setEditable(true);
    txtBrass2.setEditable(true);
    txtTransaction_No.setEditable(true);
    txtTracking_No.setEditable(true);
    public void ClearTextFields()
    //Clear the Text Fields
    txtOrder_No.setText("");
    txtCompany.setText("");
    txtLocation.setText("");
    txtDate_Shipped.setText("");
    txtBlack_Poly.setText("");
    txtBlue_Poly.setText("");
    txtBrass1.setText("");
    txtBrass2.setText("");
    txtTransaction_No.setText("");
    txtTracking_No.setText("");
    public void Add()
    //Add a new record
    showStatus("");
    //Empty the text fields
    setTextToEditable();
    ClearTextFields();
    txtOrder_No.requestFocus ();
    //Change the button labels
    btnAdd.setLabel("OK");
    btnCancel.setEnabled(true);
    //Disable the Delete and Edit buttons
    btnDelete.setEnabled(false);
    btnEdit.setEnabled(false);
    public void Save()
    //Save the new record
    // Activated when Add button has an "OK" label
    if (txtOrder_No.getText().length() == 0 && txtLocation.getText().length() == 0)
    showStatus("The Customer Name or ID Number is blank");
    else
    try
    Statement cmdDatabase = conDatabase.createStatement();
    cmdDatabase.executeUpdate(
    "Insert Into gunthmsjv.RECEIVING "
    + "(Order_No,Company,Location,Date_Shipped,Black_Poly,Blue_Poly,Brass1,Brass2,Transaction_No,txtTracking_No) "
    + "Values('"
    + txtOrder_No.getText() + "', '"
    + txtCompany.getText() + "', '"
    + txtLocation.getText() + "', '"
    + txtDate_Shipped.getText() + "', '"
    + txtBlack_Poly.getText() + "', '"
    + txtBlue_Poly.getText() + "', '"
    + txtBrass1.getText() + "', '"
    + txtBrass2.getText() + "', '"
    + txtTransaction_No.getText() + "', '"
    + txtTracking_No.getText() + "')");
    //Add to name list
    Order_No.add(txtOrder_No.getText());
    //Reset buttons
    Cancel();
    catch(SQLException error)
    showStatus("Error: " + error.toString());
    public void Delete()
    //Delete the current record
    int intIndex = Order_No.getSelectedIndex();
    String strOrder_No = Order_No.getSelectedItem();
    if(intIndex == 0) //Make sure a record is selected
    //Position zero holds a message
    showStatus("Please select the record to be deleted");
    else
    try
    //Delete from Database
    Statement cmdDatabase = conDatabase.createStatement();
    cmdDatabase.executeUpdate(
    "Delete from gunthmsjv.RECEIVING where Order_No = '"
    + strOrder_No + "';");
    ClearTextFields(); //Delete from screen
    Order_No.remove(intIndex); //Delete from list
    showStatus("Record deleted"); //Display message
    catch(SQLException error)
    showStatus("Error during Delete");
    public void Cancel()
    //Enable the Delete and Edit buttons
    btnDelete.setEnabled(true);
    btnEdit.setEnabled(true);
    btnCancel.setEnabled(false);
    //Change caption of button
    btnAdd.setLabel("Add");
    //Clear the text fields and status bar
    ClearTextFields();
    showStatus("");
    public void Edit()
    //Save the modified record
    int intIndex = Order_No.getSelectedIndex();
    if(intIndex == 0) //Make sure a record is selected
    //Position zero holds a message
    showStatus("Please select the record to be changed");
    else
    String strOrder_No = Order_No.getSelectedItem();
    try
    Statement cmdDatabase = conDatabase.createStatement();
    cmdDatabase.executeUpdate(
    "Update gunthmsjv.RECEIVING "
    + "Set Order_No = '" + txtOrder_No.getText() + "', "
    + "Company = '" + txtCompany.getText() + "', "
    + "Location = '" + txtLocation.getText() + "', "
    + "Date_Shipped = '" + txtDate_Shipped.getText() + "', "
    + "Black_Poly = '" + txtBlack_Poly.getText() + "', "
    + "Blue_Poly = '" + txtBlue_Poly.getText() + "', "
    + "Brass1 = '" + txtBrass1.getText() + "', "
    + "Brass2 = '" + txtBrass2.getText() + "', "
    + "Transaction_No = '" + txtTransaction_No.getText() + "', "
    + "txtTracking_No = '" + txtTracking_No.getText() + "', ");
    if (!strOrder_No.equals(txtOrder_No.getText()))
    //Last name changed; change the list
    Order_No.remove(intIndex); //Remove the old entry
    Order_No.add(txtOrder_No.getText()); //Add the new entry
    catch(SQLException error)
    showStatus("Error during Edit");
    public void stop()
    //Terminate the connection
    try
    if (conDatabase != null)
    conDatabase.close();
    catch(SQLException error)
    showStatus("Unable to disconnect");
    public void firstRecord()
    int first = 1;
    Order_No.select(first);
    String strNewOrder_No = Order_No.getSelectedItem();
    try
    Statement cmdDatabase = conDatabase.createStatement();
    rsDatabase = cmdDatabase.executeQuery("Select * from gunthmsjv.RECEIVING where Order_No = '" + strNewOrder_No + "';");
    txtOrder_No.setText(strNewOrder_No);
    displayRecord(rsDatabase);
    catch(SQLException error)
    showStatus("item state try.");
    public void previousRecord()
    int PreviousIndex = 0;
    PreviousIndex = Order_No.getSelectedIndex();
    PreviousIndex--;
    if (PreviousIndex > 0)
    Order_No.select(PreviousIndex);
    String strNewOrder_No = Order_No.getSelectedItem();
    try
    Statement cmdDatabase = conDatabase.createStatement();
    rsDatabase = cmdDatabase.executeQuery("Select * from gunthmsjv.RECEIVING where Order_No = '" + strNewOrder_No + "';");
    txtOrder_No.setText(strNewOrder_No);
    displayRecord(rsDatabase);
    catch(SQLException error)
    showStatus("item state try.");
    else
    showStatus("You've reached the beginning of the list.");
    public void nextRecord()
    int NextIndex = 0;
    NextIndex = Order_No.getSelectedIndex();
    if(NextIndex == 0)
    NextIndex = 1;
    else
    NextIndex++;
    if (NextIndex < Order_No.getItemCount())
    Order_No.select(NextIndex);
    String strNewOrder_No = Order_No.getSelectedItem();
    try
    Statement cmdDatabase = conDatabase.createStatement();
    rsDatabase = cmdDatabase.executeQuery("Select * from gunthmsjv.RECEIVING where Order_No = '" + strNewOrder_No + "';");
    txtOrder_No.setText(strNewOrder_No);
    displayRecord(rsDatabase);
    catch(SQLException error)
    showStatus("item state try.");
    else
    showStatus("You've reached the end of the list.");
    public void lastRecord()
    int last = 0;
    while (last < Order_No.getItemCount()-1)
    last++;
    Order_No.select(last);
    String strNewOrder_No = Order_No.getSelectedItem();
    try
    Statement cmdDatabase = conDatabase.createStatement();
    rsDatabase = cmdDatabase.executeQuery("Select * from gunthmsjv.RECEIVING where Order_No = '" + strNewOrder_No + "';");
    txtOrder_No.setText(strNewOrder_No);
    displayRecord(rsDatabase);
    catch(SQLException error)
    showStatus("item state try.");
    How do I point the class.forname to a url? This class will be run off a webserver with an html file. Everytime I run it currently, it comes back with a NullPointerException so I know it can't find it. I know if I run it locally, the file runs properly... Can someone help ASAP :(

    oad: class http://www.auburn.edu/~gunthms/classes/shipping.class not found.
    java.lang.ClassNotFoundException: http:..www.auburn.edu.~gunthms.classes.shipping.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.net.UnknownHostException: www
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at sun.net.NetworkClient.doConnect(Unknown Source)
         at sun.plugin.net.protocol.http.HttpClient.doConnect(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.<init>(Unknown Source)
         at sun.net.www.http.HttpClient.<init>(Unknown Source)
         at sun.plugin.net.protocol.http.HttpClient.<init>(Unknown Source)
         at sun.plugin.net.protocol.http.HttpClient.New(Unknown Source)
         at sun.plugin.net.protocol.http.HttpURLConnection.createConnection(Unknown Source)
         at sun.plugin.net.protocol.http.HttpURLConnection.connect(Unknown Source)
         at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
         at java.net.HttpURLConnection.getResponseCode(Unknown Source)
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more
    It's just not finding it. Now if there were a way of loading that class from a jar file... or just any method at all of loading that... I think it would work... thanks alot man for your continuing help.

  • Help. JDBCRealm error -- org.gjt.mm.mysql.Driver not found

    Hi All,
    I tried to setup JDBCRealm. After I config. to JDBCRealm and restart tomcat. I got this error:
    java.sql.SQLException: org.git.mm.mysql.Driver error.
    Can someone help. Thanks

    web-inf/lib is not sufficient in this case, as the Tomcat engine needs access to the driver - not just your application.
    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/realm-howto.html#JDBCRealm
    You need to
    Place a copy of the JDBC driver you will be using inside the $CATALINA_HOME/server/lib directory (if you do not need it visible to web applications) or $CATALINA_HOME/common/lib (if it will be used both by Tomcat 4 and by your apps).
    Cheers.
    evnafets

  • Org.gjt.mm.mysql.Driver not found help!!

    hi all
    it's the first time for me working with MySql, and when i try to connect to the db, i have the following exception:
    java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
    i know that i shall download it from Mysql site, but i don't know WHERE to put it
    i'm using forte 3.0 - jdk 1.4.0 on Win2K
    please help me!
    thanx
    sandro

    No problem,
    in general you should modify the CLASSPATH of your JDK to point to the jar-driver-file, e.g. (on unix): CLASSPATH = "someDirectory"\driverFIle.jar:$CLASSPATH
    and then: export CLASSPATH. That should solve your problem. if using windows: Just take a look at systemControlCenter. There it's possible to modify the CLASSPAT-environment.
    So far...

  • Help me i need mm.mysql driver for my sql

    i tried to connect my jsp page with mysql database but it is giving me type 4 org.gjt.mm.mysql.Driver error it says that it is not found.
    i went to mysql official site and it is saying that they have finished mm driver and now have made connector j driver for jdbc ....
    my code is this...
    <%
    Class.forName("org.gjt.mm.mysql.Driver");
    Connection myConn= DriverManager.getConnection("jdbc:mysql:///poll?user=123&password=123");
    Statement stmt=myConn.createStatement();
    ResultSet myResultSet=stmt.executeQuery("select * from pollInfo");
    if (myResultSet != null){
    while (myResultSet.next()){
    String name=myResultSet.getString ("pollname");
    String option=myResultSet.getString ("pollOption");
    String votes=myResultSet.getString ("pollvotes");%>
    <tr>
    <td><%=name%></td>
    <td><%=option%></td>
    <td><%=votes%></td>
    </tr>
    <%
    stmt.close();
    myConn.close();
    %>
    here poll is my database name and pollInfo is my table name
    user name and passwords are 123
    and when running it it give me this error.
    >>>>>>>>>>>>>>>>>>>>>
    500 Internal Server Error
    /dbquery.jsp:
    Exception thrown on line '11' from page 'C:\\Program Files\\Allaire\\JRun\\servers\\default\\default-app\\dbquery.jsp'.
    java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver [org.gjt.mm.mysql.Driver]
         at allaire.jrun.servlet.JRunServletLoader.loadClass(../servlet/JRunServletLoader.java:430)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at allaire.jrun.jsp.JSPClassLoader.loadClass(../jsp/JSPClassLoader.java:118)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at jrun__dbquery2ejspc._jspService(jrun__dbquery2ejspc.java:44)
         at allaire.jrun.jsp.HttpJSPServlet.service(../jsp/HttpJSPServlet.java:39)
         at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:228)
         at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:196)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1416)
         at allaire.jrun.session.JRunSessionService.service(../session/JRunSessionService.java:1082)
         at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:1270)
         at allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDispatcher.java:89)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1552)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1542)
         at allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:364)
         at allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:115)
         at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
         at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    I am using jrun 3.1 the release of Allair ...
    now any one please help me what to do
    i willl be great ful to all of u very much thanx
    bye

    Hi,
    The driver needs to be on your classpath. So download it to (say C:\jars), what I do is rename it to mysql.jar
    Then add the C:\jars\mysql.jar to the classpath
    If you are using it with tomcat at runtime, which you are probably not, then you could also copy the jar in the tomcat\lib directory - but I have never done this.
    If you are still experiencing problems, open the jar file using winxip or the jar command and make sure that the jar build is exactly as it should be, i.e. the correct names etc.
    best
    kev

  • How to load mysql driver in netbeans 5.0

    I configured mysql driver(com.mysql.jdbc.Driver) in netbeans 5.0. but i got this type of errors
    (run:
    Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at gdb.gdbop.main(gdbop.java:20))
    plz help me for this...............

    IDEs such as netbeans and eclipse require you to add any external jars to the project's classpath.
    for netbeans 5.0, see here:
    http://www.netbeans.org/kb/50/using-netbeans/project_setup.html#pgfId-1157099

  • How to import MySQL Driver in Jbuilder

    I am creating a GUI application using swing with the help of JBuilder. I have used MySQL as Database. For connection it to java I've used MySQL J-Connector Driver. But I am not being able to import that driver(classes) in jbuilder.
    When i run the application at the cmd prompt it works fine (got connected), but when i try to run it under jbuilder it gives error like
    java.com.mysql.Driver class not found.
    I think it is classpath problem
    Please help me, setting this problem

    No, you need not import class as you give qualified
    class name in Class.forName(). Better post your code
    here. Somebody will help you out.Below is the code of CLASS CreateConnection, I'm using to create connection to MySQL. I instantiate this class and use the connection. This class is being called when a connection to database is required. I am creating a desktop application using swing.
    package project1;
    import java.sql.*;
    public class CreateConnection {
         private String host,database,username,password;
         String db_string;
         Connection conn;
         Statement smt;
         ResultSet rs;
    //Parameterized constructor
         CreateConnection(String host, String database, String username, String password){
              this.host=host;
              this.database=database;
              this.username=username;
              this.password=password;
    db_string="jdbc:mysql://"+host+"/"+database+"?user="+username+"&password="+password ;
    create();
    //Parameterized constructor 2
    CreateConnection(String db_string){
    this.db_string=db_string;
    create();
    public void create(){
              System.out.println("using: " +db_string);
              try{
                   System.out.println("Loading drivers........");
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
                   System.out.println("Driver loaded !");
                   conn = DriverManager.getConnection(db_string);
                   smt = conn.createStatement();
                   System.out.println("testing database .........");
                   smt.execute("create table test(no varchar(22))");
              catch(Exception e){
                   System.out.println(e);
                   System.exit(0);
         System.out.println("Successfull");
    public ResultSet execute_q(String query){
              try{
                   System.out.println("Executing "+query);
                   rs=smt.executeQuery(query);
              catch(SQLException sqle){
                   System.out.println("Execption thrown" +sqle);
                   return null;
              return rs;
    }

  • Working with MySQL driver

    I'm trying to use MySql Driver instead of ODBC in an application developed with JBuider.
    When the instruction:
    Class.forName("com.mysql.jdbc.Driver");
    is processed I receive the message:
    Class Driver ERROR java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    Where should I put mysql-connector-java-3.0.8-stable-bin.jar?????
    Please help me
    Thanks to everyone

    I think that JBuilder doesn't use system classpath but build it by his run configuration.
    What I don't understand is how to include my .jar in it.
    bye

  • Kodo not recovering from bad connection in new MySQL driver

    Hi,
         I'm using kodo 2.4.1 and the latest stable MySQL driver 3.0.6. After
    leaving the application inactive for a few hours, the connection to
    mysql is no longer usable. This did not occur with MySQL version 2.0.14
    (as I believe Kodo weren't reusing the connections).
         Are there any properties that I could set, so Kodo can keep the
    connection active or recover from the problem?
    Makas

    Ok, thanks Marc, like I said though, I am now re-using MySQL 2.0.14
    driver. I'm not sure if I'm gaining any advantages with MySQL 3.0.6 anyway.
    But I'll probably upgrade it after the next Kodo is released.
    Makas
    Marc Prud'hommeaux wrote:
    Makas-
    Sorry ... I didn't test the property I sent. The problem is that our
    options parsing does not deal with spaces (this will be fixed in the
    next release).
    Instead of ValidateConnectionSQL="SELECT 1", you should be able to use
    ValidateConnectionSQL=SELECT(1), which does not contain spaces.
    In article <[email protected]>, Makas Tzavellas wrote:
    Marc,
    Using the properties you wrote, kodo doesn't seems to be able to parse
    it. I've also tried various other combinations with no success. I'm now
    going to use the older mysql driver.
    Marc Prud'hommeaux wrote:
    Makas-
    Kodo should be re-using the MySQL Connection in exactly the same way,
    regardless of the version. The problem is that it looks like MySQL people
    slipped in an "optimization" into 3.0.6 whereby Connection.isClosed()
    does not actually test the state of the Connection, but instead just
    returns true if and only if Connection.close() has been invoked.
    You can get around this by specifying some SQL to validate the
    Connections. The following property should do the trick:
    com.solarmetric.kodo.impl.jdbc.DictionaryProperties=\
    ValidateConnections=true \
    ValidateConnectionSQL="SELECT 1"
    Please let us know if the problem persists.
    In article <[email protected]>, Makas Tzavellas wrote:
    Hi Marc,
         Here're the stack trace of the exception and the kodo properties. There
    isn't any long running transaction. The application is basically left
    idle for some time and subsequent connections fails. It could be
    connections obtained from the pool, but I'm not sure.
         I will re-use mysql 2.0.14 for now. Please let me know if I'm missing
    any other properties or if you need more info.
    # Kodo JDO Properties configuration
    # To evaluate or purchase a license key, visit http://www.solarmetric.com
    com.solarmetric.kodo.CacheReferenceSize=1000
    com.solarmetric.kodo.ee.ManagedRuntimeProperties=TransactionManagerName=java:/TransactionManager
    javax.jdo.PersistenceManagerFactoryClass=com.solarmetric.kodo.impl.jdbc.JDBCPersistenceManagerFactory
    javax.jdo.option.ConnectionDriverName=org.gjt.mm.mysql.Driver
    javax.jdo.option.ConnectionUserName=
    javax.jdo.option.ConnectionPassword=
    javax.jdo.option.ConnectionURL=jdbc:mysql://hostname/database?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true
    javax.jdo.option.MinPool=0
    javax.jdo.option.MaxPool=20
    javax.jdo.option.Optimistic=true
    javax.jdo.option.RetainValues=true
    javax.jdo.option.NontransactionalRead=false
    com.solarmetric.kodo.impl.jdbc.ConnectionTestTimeout=10
    com.solarmetric.kodo.impl.jdbc.AutoReturnTimeout=10
    com.solarmetric.kodo.impl.jdbc.DictionaryClass=com.solarmetric.kodo.impl.jdbc.schema.dict.MySQLDictionary
    com.solarmetric.kodo.DataCacheProperties=Port=5555
    Addresses=repository2.kl.ewarna.com:5555;repository.kl.ewarna.com:5555
    CacheSize=5000
    com.solarmetric.kodo.DataCacheClass=com.ewarna.pdm.sessions.PDMCache
    =========== Stack Trace ================================
    Communication link failure: java.io.IOException [code=0;state=08S01]
    NestedThrowables:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
    [SQL=SELECT t0.M_IDX, t3.JDOCLASSX, t3.JDOLOCKX, t3.M_CREATIONDATEX,
    t3.M_DELETEDDATEX, t3.M_HOSTADDRESSX, t3.M_LASTMODIFIEDDATEX,
    t3.M_NAMEX, t3.M_OLDIDX, t3.M_ID_M_OWNERX, t0.M_ID_M_ACCOUNTX,
    t0.M_FULLNAMEX, t0.M_PASSWORDX, t0.M_PASSWORDEXPIRYDATEX, t3.M_NAMEX
    >>>>FROM ABSTRACTENTITYX t2, ABSTRACTENTITYX t3, Accounts t1, Users t0 WHERE>>>>>>>((((((t2.M_NAMEX = 'development' AND t3.M_NAMEX = 'ewarna') AND>>>>(t3.M_DELETEDDATEX IS NULL)) AND (t2.M_DELETEDDATEX IS NULL)) AND>>>>(t3.M_DELETEDDATEX IS NULL)) AND t3.JDOCLASSX =>>>>'com.ewarna.pdm.entities.storage.UserPE') AND t0.M_IDX = t3.M_IDX AND>>>>t0.M_ID_M_ACCOUNTX = t1.M_IDX AND t1.M_IDX = t2.M_IDX) ORDER BY>>>>t3.M_NAMEX ASC
    [PRE=SELECT t0.M_IDX, t3.JDOCLASSX, t3.JDOLOCKX, t3.M_CREATIONDATEX,
    t3.M_DELETEDDATEX, t3.M_HOSTADDRESSX, t3.M_LASTMODIFIEDDATEX,
    t3.M_NAMEX, t3.M_OLDIDX, t3.M_ID_M_OWNERX, t0.M_ID_M_ACCOUNTX,
    t0.M_FULLNAMEX, t0.M_PASSWORDX, t0.M_PASSWORDEXPIRYDATEX, t3.M_NAMEX
    >>>>FROM ABSTRACTENTITYX t2, ABSTRACTENTITYX t3, Accounts t1, Users t0 WHERE>>>>>>>((((((t2.M_NAMEX = ? AND t3.M_NAMEX = ?) AND (t3.M_DELETEDDATEX IS>>>>NULL)) AND (t2.M_DELETEDDATEX IS NULL)) AND (t3.M_DELETEDDATEX IS NULL))>>>>AND t3.JDOCLASSX = ?) AND t0.M_IDX = t3.M_IDX AND t0.M_ID_M_ACCOUNTX =>>>>t1.M_IDX AND t1.M_IDX = t2.M_IDX) ORDER BY t3.M_NAMEX ASC
    Communication link failure: java.io.IOException
         at
    com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwDataStore(SQLExceptions.java:23)
         at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCStoreManager.java:742)
         at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.executeQuery(JDBCQuery.java:92)
         at com.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:792)
         at
    com.ewarna.pdm.sessions.BasicQuery.getByAdvancedFormula(BasicQuery.java:137)
         at
    com.ewarna.pdm.sessions.BasicQuery.getByAdvancedFormula(BasicQuery.java:65)
         at com.ewarna.pdm.sessions.BasicQuery.getByFormula(BasicQuery.java:205)
         at
    com.ewarna.handlers.storage.SessionHandler$1.execute(SessionHandler.java:116)
         at
    com.ewarna.pdm.sessions.JDOCallBackExecutor.execute(JDOCallBackExecutor.java:40)
         at
    com.ewarna.handlers.storage.SessionHandler.login(SessionHandler.java:140)
         at
    com.ewarna.pdm.soap.AbstractSoapService.login(AbstractSoapService.java:44)
         at
    com.ewarna.pdm.soap.xfs.SoapServiceXFSImpl.login(SoapServiceXFSImpl.java:1199)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at org.apache.soap.server.RPCRouter.invoke(RPCRouter.java:146)
         at
    org.apache.soap.providers.RPCJavaProvider.invoke(RPCJavaProvider.java:129)
         at
    org.apache.soap.server.http.RPCRouterServlet.doPost(RPCRouterServlet.java:354)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at
    org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
         at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at
    org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
         at
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
         at
    org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
         at
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
         at java.lang.Thread.run(Thread.java:536)
    NestedThrowablesStackTrace:
    java.sql.SQLException: Communication link failure: java.io.IOException
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1606)
         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:886)
         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:945)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:1809)
         at
    com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1458)
         at
    com.solarmetric.datasource.PreparedStatementWrapper.executeQuery(PreparedStatementWrapper.java:93)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedQueryInternal(SQLExecutionManagerImpl.java:769)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeQueryInternal(SQLExecutionManagerImpl.java:692)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeQuery(SQLExecutionManagerImpl.java:373)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeQuery(SQLExecutionManagerImpl.java:357)
         at
    com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.selectPrimaryMappings(ClassMapping.java:1221)
         at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCStoreManager.java:717)
         at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.executeQuery(JDBCQuery.java:92)
         at com.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:792)
         at
    com.ewarna.pdm.sessions.BasicQuery.getByAdvancedFormula(BasicQuery.java:137)
         at
    com.ewarna.pdm.sessions.BasicQuery.getByAdvancedFormula(BasicQuery.java:65)
         at com.ewarna.pdm.sessions.BasicQuery.getByFormula(BasicQuery.java:205)
         at
    com.ewarna.handlers.storage.SessionHandler$1.execute(SessionHandler.java:116)
         at
    com.ewarna.pdm.sessions.JDOCallBackExecutor.execute(JDOCallBackExecutor.java:40)
         at
    com.ewarna.handlers.storage.SessionHandler.login(SessionHandler.java:140)
         at
    com.ewarna.pdm.soap.AbstractSoapService.login(AbstractSoapService.java:44)
         at
    com.ewarna.pdm.soap.xfs.SoapServiceXFSImpl.login(SoapServiceXFSImpl.java:1199)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at org.apache.soap.server.RPCRouter.invoke(RPCRouter.java:146)
         at
    org.apache.soap.providers.RPCJavaProvider.invoke(RPCJavaProvider.java:129)
         at
    org.apache.soap.server.http.RPCRouterServlet.doPost(RPCRouterServlet.java:354)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at
    org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
         at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at
    org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
         at
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
         at
    org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
         at
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
         at java.lang.Thread.run(Thread.java:536)
    Marc Prud'hommeaux wrote:
    Makas-
    Is Kodo idle during a long-running transaction, or does the error occur
    when a new Connection is allocated? If the former, then there is nothing
    we can do: MySQL shouldn't be dropping an open Connection while a
    transaction is active. If the latter, then the property
    com.solarmetric.kodo.impl.jdbc.ConnectionTestTimeout specified the
    number of seconds between which the connection should be tested for
    valididty when removed from the pool.
    See also:
    http://docs.solarmetric.com/manual.html#com.solarmetric.kodo.impl.jdbc.ConnectionTestTimeout
    If this does not help, can you let us know your properties and some
    details about your application?
    In article <[email protected]>, Makas Tzavellas wrote:
    Hi,
         I'm using kodo 2.4.1 and the latest stable MySQL driver 3.0.6. After
    leaving the application inactive for a few hours, the connection to
    mysql is no longer usable. This did not occur with MySQL version 2.0.14
    (as I believe Kodo weren't reusing the connections).
         Are there any properties that I could set, so Kodo can keep the
    connection active or recover from the problem?
    Makas

  • Mm.mysql Driver problems

    Im trying to get Tomcat to function with mysql database.
    I am using Tomcat 4.0.
    I recieve this error when trying to connect to mysql:
    javax.servlet.ServletException: org.gjt.mm.mysql.Driver
    java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
    I have a classpath setting of:
    C:\jdk\lib\mysql.jar
    I dont know why it is not finding the class... Maybe its a problem with Tomcat 4.0??

    Jim
    Here is code I use to connect:
    context = Server.getContext();
         try {
         String dbName = context.getInitParameter("DbName");
         String dbUsr = context.getInitParameter("DbUserName");
         String dbPwd = context.getInitParameter("DbUserPwd");
         String conStr = "jdbc:mysql://localhost/" + dbName + "?user=" + dbUsr + "&password=" + dbPwd;
         Class.forName("org.gjt.mm.mysql.Driver").newInstance();
         dbCon = DriverManager.getConnection(conStr);
         } catch (Exception ex) {
    Server.logErr("DBManager: failed to init connection",ex);
    throw ex;
    I am using Tomcat 3.2.1 with mm.mysql 2.0.4 and it all seems to work fine.
    Hope this helps
    Regards
    David

  • How to bound a JNDI reference to MySQL driver?

    Hi.
    Hi.
    I am trying to write a simple J2EE application that would use Entety EJB with bean persisatance. I have downloaded driver from the www.mysql.org, copied it to the lib/system directory and modified J2EE_CLASSPATH in bin/userconfig.bat. I am using reference implementation server and with deploytool in �tools/serverconfiguration/datasourses/standard� I am specifying driver: org.gjt.mm.mysql.Driver or com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource and in datasourses in JNDI Name I write �jdbc/mydb� and in JDBC URL �jdbc:mysql://localhost:3306/this�, problem comes up when I try to reference �jdbc/mydb� from an entity bean, during deployment process of application it says that it is not bound
    Binding name:`java:comp/env/jdbc\persondb`
    Warning: Reference reference java:comp/env/jdbc\persondb is using a JNDI name that is not bound: jdbc\mydb
    I do not get it, what I am doing wrong? Please help me to find out how to bind a JNDI name to MySQL

    Hi! I had the same problem, too. I�m Brazilian and I�ve been learning the English language yet, but I�ll try to describe how to configure J2EE with MySQL.
    I am using MySQL version 4.1.7 with J2EE version 1.3 on Windows XP Professional. The driver version of MySQL is 3.0.16.
    You have to configure the following two files:
    - <J2EE_HOME>\bin\setenv.bat
    - <J2EE_HOME>\config\resource.properties
    Do the following steps:
    1) Copy the JAR file of MySQL driver (mysql-connector-java-3.0.16-ga-bin.jar) to <J2EE_HOME>\lib directory.
    2) In <J2EE_HOME>\bin directory open the setenv.bat file and analize the code. It is not hard to understand the code, it is just the classpath configuration of J2EE. After understand it, add a reference of MySQL driver (mysql-connector-java-3.0.16-ga-bin.jar), that was copied to <J2EE_HOME>\lib directory.
    3) Run the <J2EE_HOME>\bin\j2eeadmin.bat to configure the resource.properties file.There are two command lines to be executed, as below:
    - j2eeadmin.bat -addJdbcDriver <CLASS NAME OF THE DRIVER>
    - j2eeadmin.bat -addJdbcDatasource <JNDI NAME> <URL>
    For example:
    - j2eeadmin.bat -addJdbcDriver "com.mysql.jdbc.Driver"
    - j2eeadmin.bat -addJdbcDatasource "jdbc/mysql/test" "jdbc:mysql://localhost/test?user=username&password=pass"
    4) After run j2eeadmin.bat, the resource.properties file will be modified. But when I did it and when I executed the verbose command to start J2EE, some error messages was exhibited. So I decided to open the resource.properties file and I noticed that the character "\" was added erroneously in a lot of places of the code. It did not seem correct, so I decided to remove these characters replacing them. I was right! After I did it, I run verbose again and no more message error ocurred. I think it is a bug of J2EE.
    Finish! I modified the datasource JNDI to access MySQL and then I run my EAR application. No problems occurred. My application is running succesfully.
    Good luck!

  • Problem with a j2se program and mysql driver

    Hi,
    We are developing an application which needs accessing to a mysql database. I have packed the application in a .jar. and inside the jar I have created a folder lib. And inside that folder I have put mysql driver.
    As the same way, I have been reading in SDN forum, I have edited manifiest file and I have writen this:
    Manifest-Version: 1.0
    Sealed: true
    Class-Path: lib/mysql-connector-java-5.0.4-bin.jar
    Main-Class: package1.Main
    When I introduce this command java -jar program1.jar, the jvm says this:
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    I know when I use java -jar, classpath system variable doesn't mind. But even this variable is set up properly. If you could help me it would be great. I'm getting stuck with this.
    Thanks in advance.

    @CiMaBuE wrote:
    Hi,
    We are developing an application which needs accessing to a mysql database. I have packed the application in a .jar. and inside the jar I have created a folder lib. And inside that folder I have put mysql driver.That's the problem. JARs don't look inside themselves for 3rd party JARs. That /lib directory needs to be relative to the program1.jar that you created.
    I believe modules or OSGi are supposed to address this, but executable JARs do not today.
    %

  • Help with mysql class (Japplet)

    Hi,I have found program that exactly what i want in Japplet ,but its not clean i wana use it on my other classes . Here is what i tired from changing .After all,i am not professionnel in java.
    The ORGINAL HERE :
      http://forum.java.sun.com/thread.jsp?forum=4&thread=197844
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.net.URL;
    import java.sql.*;
    import java.util.*;
    import java.util.Properties;
    import java.net.URL;
    import java.sql.*;
    public class Sql extends JApplet
        public String  tfDrv = null, tfSQL = null;
        //public String dbUser,dbPass;
        Connection conn = null;
        private Statement stmt =null;
        /*public Sql() {
        public void init() {
        private void initialize( String dbUser,String dbPass,String tfDrv ) {
                initDB("jdbc:mysql://localhost/mysql",dbUser,dbPass,tfDrv);
        private void initDB(String connect,String user,String pass,String tfDrv) {
        try {
            String url = connect;
            this.tfDrv=tfDrv;
            Class.forName("org.gjt.mm.mysql.Driver");
            conn = DriverManager.getConnection( url, user, pass );//should get name, pwd
        } catch( Exception e ) {
            e.printStackTrace();
        public ResultSet executeSQL( String sql )  throws Exception {
        System.out.println( "DS exSQL " + sql );
        int irs = 0;
        ResultSet rs = null;
        try {
            stmt = conn.createStatement();
            boolean bo = stmt.execute("use "+ this.tfDrv);
            if( sql.startsWith( "select" ) ) {
            rs = stmt.executeQuery( sql );
            System.out.println( "xq rs: " + rs );
            else if( sql.startsWith( "delete" ) ||
                 sql.startsWith( "insert" ) ) {
            irs = stmt.executeUpdate( sql );
            else if( sql.startsWith( "update" ) ) {
            irs = stmt.executeUpdate( sql );
        catch( Exception e ) {
            System.out.println(e.getMessage());
            e.printStackTrace();
            throw e;
        return rs;
        private DefaultTableModel doSQL( String sql ) {
        DefaultTableModel m = new DefaultTableModel();
        java.util.Vector data = new java.util.Vector();
        java.util.Vector headers = new java.util.Vector();
        try {
            String s = "";
            ResultSet rs = executeSQL( sql );
            System.out.println( "rs " + rs );
            ResultSetMetaData rsmd = rs.getMetaData();
            ////List datas  = new LinkedList();   
            ////datas = new ArrayList();
            for( int c = 1, cc = rsmd.getColumnCount(); c <= cc; c++ ) {
            headers.addElement( rsmd.getColumnName( c ) );
            java.util.Vector datum = null;
            while( rs.next() )
                datum = new java.util.Vector();
                for( int c = 1, cc = rsmd.getColumnCount(); c <= cc; c++ ) {
                s = rs.getString( c );
                datum.addElement( s );
                data.addElement( datum );
        } catch( Exception e ) {
            e.printStackTrace();
        m.setDataVector( data, headers );
        System.out.println( "d: " + data );
        return m;
        public static void main( String[] args )   throws Exception{
        Sql rb = new Sql();
        ResultSet rs;
        rb.initialize( "root","root","test" );
         //rb.doSQL("DELETE FROM `oop` WHERE `oop`.`java` = 2");
        rs = rb.executeSQL("DELETE FROM `oop` WHERE `oop`.`java` = 2");
        System.out.println(rs.getString("1"));
    }

    Ok Sorry
    This the same program after edditing and its works great
    but the problem i don't want GUI I want to use it in other classes to connect to mysql database .So please Help.
      http://forum.java.sun.com/thread.jsp?forum=4&thread=197844
            permission java.lang.RuntimePermission "accessClassInPackage.sun.jdbc.odbc";
         permission java.util.PropertyPermission "file.encoding", "read";
            permission java.net.SocketPermission "*:*", "connect,listen,resolve,accept";
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.net.URL;
    import java.sql.*;
    import java.util.*;
    import java.util.Properties;
    import java.net.URL;
    import java.sql.*;
    public class yesSql extends JApplet
        private JTextField tfDrv = null, tfSQL = null;
        Connection conn = null;
        private Statement stmt =null;
        public yesSql() {
        public void init() {
         initialize( (JPanel) getContentPane() );
        private void initialize( JPanel p ) {
         p.setLayout( new BorderLayout() );
         JLabel lDrv = new JLabel( "DB Name: " );
         tfDrv = new JTextField( 25 );
         tfDrv.setText( "mysql" );
         JPanel pp = new JPanel();
         pp.setLayout( new GridLayout( 6, 2 ) );
         pp.add( lDrv );
         pp.add( tfDrv );
         JLabel lSQL = new JLabel( "SQL" );
         tfSQL = new JTextField( 25 );
         tfSQL.setText( "select * from " );
         pp.add( lSQL );
         pp.add( tfSQL );
         JButton b = new JButton( "Submit" );
         b.addActionListener( new ActionListener() {
              public void actionPerformed( ActionEvent ev ) {
                 initDB("jdbc:mysql://localhost/mysql","root","root");
                  initTable( (JPanel) getContentPane() );
         pp.add( b );
         p.add( "North", pp );
        private void initDB(String connect,String user,String pass) {
         try {
             String url = connect;
             String drv = tfDrv.getText();
    //         DriverManager.registerDriver( new sun.jdbc.odbc.JdbcOdbcDriver() );
            Class.forName("org.gjt.mm.mysql.Driver");
             conn = DriverManager.getConnection( url, user, pass );//should get name, pwd
             System.out.println( "d: " + drv + ", u: " + url );
         } catch( Exception e ) {
             e.printStackTrace();
        public ResultSet executeSQL( String sql ) throws Exception {
         System.out.println( "DS exSQL " + sql );
         int irs = 0;
         ResultSet rs = null;
         try {
             stmt = conn.createStatement();
             boolean bo = stmt.execute("use "+ tfDrv.getText());
             if( sql.startsWith( "select" ) ) {
              rs = stmt.executeQuery( sql );
              System.out.println( "xq rs: " + rs );
             else if( sql.startsWith( "delete" ) ||
                   sql.startsWith( "insert" ) ) {
              irs = stmt.executeUpdate( sql );
             else if( sql.startsWith( "update" ) ) {
              irs = stmt.executeUpdate( sql );
         catch( Exception e ) {
             System.out.println(e.getMessage());
             e.printStackTrace();
             throw e;
         return rs;
        private DefaultTableModel doSQL( String sql ) {
         DefaultTableModel m = new DefaultTableModel();
         java.util.Vector data = new java.util.Vector();
         java.util.Vector headers = new java.util.Vector();
         try {
             String s = "";
             ResultSet rs = executeSQL( sql );
             System.out.println( "rs " + rs );
             ResultSetMetaData rsmd = rs.getMetaData();
             for( int c = 1, cc = rsmd.getColumnCount(); c <= cc; c++ ) {
              headers.addElement( rsmd.getColumnName( c ) );
             java.util.Vector datum = null;
             while( rs.next() )
                  datum = new java.util.Vector();
                  for( int c = 1, cc = rsmd.getColumnCount(); c <= cc; c++ ) {
                   s = rs.getString( c );
                   datum.addElement( s );
                  data.addElement( datum );
         } catch( Exception e ) {
             e.printStackTrace();
         m.setDataVector( data, headers );
         System.out.println( "d: " + data );
         return m;
        private void initTable( JPanel p ) {
         DefaultTableModel dtm = doSQL( tfSQL.getText() );
         JTable tb = new JTable( dtm );
         JScrollPane sp = new JScrollPane( tb );
         JFrame fr = new JFrame();
         fr.getContentPane().add( sp );
         fr.pack();
         fr.show();
        public static void main( String[] args ) {
         JFrame f = new JFrame();
         yesSql rb = new yesSql();
         JPanel p = (JPanel) f.getContentPane();
         rb.initialize( p );
         f.pack();
         f.show();
    }

  • Help with mySQL Connection string

    Here is hoping someone can help & once I get it down I promise I'll post all my work on this list so some other newbie can benefit.
    I'm simply trying to run a very very straightforward JDBC test with mySQL & I keep getting the "Server configuration denies access to data source" error. But before you tell me that I must simply look at what my mysql.db & mysql.user table allows - I'VE TRIED THAT. I realize that the error is probably there somewhere - but I can't see it.
    I've tried connecting with 2 different accounts - the provided "root" & a user I created "deep" to 2 different databases the provided "test" & "testdb" which I created) . Here is what mysql says about the two different databases
    mysql> select * from db;
    Host  | Db         | User |.......
    -----+------------+-------
    | %         | test    |       | ......
    | %         | test\_% |     | ........
    | localhost | testdb  | deep |........Note that "root" should have access to "test" & deep@localhost should have access to "testdb" right?
    So here are all the connection strings I have tried - all return the same error below
            Connection conn = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/test", "root", "mypass"
    //            "jdbc:mysql://localhost:3306/testdb", "deep", "mypass"
    //            "jdbc:mysql://localhost/testdb?user=deep&password=mypass"
    //            "jdbc:mysql://localhost/testdb", "deep", "mypass"
    //            "jdbc:mysql://localhost:3306/testdb?user=deep@localhost&password=mypass"
    //            "jdbc:mysql://localhost:3306/testdb?user=deep&password=mypass"
    //            "jdbc:mysql://localhost/testdb", "deep@localhost", "mypass"
    //            "jdbc:mysql:///test", "root", "mypass"
    //            "jdbc:mysql://localhost/test", "root@localhost", "mypass"
    );My Error:
    Exception in thread "main" java.sql.SQLException: Server configuration denies access to data source
            at org.gjt.mm.mysql.MysqlIO.init(MysqlIO.java:193)
            at org.gjt.mm.mysql.Connection.connectionInit(Connection.java:261)
            at org.gjt.mm.mysql.jdbc2.Connection.connectionInit(Connection.java:89)
            at org.gjt.mm.mysql.Driver.connect(Driver.java:167)
            at java.sql.DriverManager.getConnection(DriverManager.java:517)
            at java.sql.DriverManager.getConnection(DriverManager.java:199)
            at TestMySQL4.main(TestMySQL4.java:76)BTW:
    I am using MacOSX 10.1
    MySQL 3.23.42
    The driver is: mm.mysql-2.0.6.jar
    Please help!
    'deep

    hi amandeep
    well i m getting the same error message when trying to connect MYSQL using mm.jdbc driver.
    java.sql.SQLException : Server configuration denies access to data base source.
    query.jdbcDriver org.gjt.mm.mysql.Driver
    query.databaseURL jdbc:mysql://aaa.bbb.com/pluto
    query.databaseUserName samin
    query.databasePwd samin
    query.summaries true
    i hve installed mysql on server aaa.bbb.com network 1
    and trying to run application on network 2
    Thanks
    samir

  • Java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver...the same old pr

    Hi,
    I am a new user in this forum..
    I have just installed tomcat and mysql and jdbc fresh on my new system..
    first of all here is what i have done...
    i have installed mysql integrated in xampp at c:\xampp\mysql
    i have installed my tomcat at C:\Programme\Apache Software Foundation\Tomcat 5.5
    i have put jdbc <dirver>.jar file copied in all sorts of directories like ....
    <tomcat_home>\common\lib
    <tomcat_home>\webapps\axis\WEB-INF\lib\ext
    <java_home>\lib
    <java_home>\jre\lib\ext
    my calsspath looks something like this
    .;C:\Programme\QuickTime\QTSystem\QTJava.zip;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\common\lib\mysql-connector-java-5.0.6-bin.jar;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\webapps\axis\WEB-INF\lib\mysql-connector-java-5.0.6-bin.jar;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\common\lib\servlet-api.jar;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\common\lib\jsp-api.jar;C:\Programme\Java\jdk1.5.0_05\jre\lib\ext\mysql-connector-java-5.0.6-bin.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\activation.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\axis.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\axis-ant.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\commons-logging-1.0.4.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\jaxrpc.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\log4j-1.2.8.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\mail.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\saaj.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\mysql-connector-java-5.0.6-bin.jar
    which is basically all the jar files in the web-inf\lib folder and references to all the copies of driver as mentioned before
    these are results of a lot of desperatio but still the code which i run....
    package mypackage;
    import java.sql.*;
    public class JDBCConnector
    public static void main(String[] arg) throws Exception
         System.out.println("Initiating Database Mysql Connection");
         //try {
                   Statement stmt;
                        //     Register the JDBC driver for MySQL.
                   Class.forName("org.gjt.mm.mysql.Driver ").newInstance();
                        //     Define URL of database server for
                        // database named mysql on the localhost
                        //      with the default port number 3306.
                   String url = "jdbc:mysql://wifh-1.fhso.ch:3306/";
                        //          Get a connection to the database for a
                        // user named root with a blank password.
                        // This user is the default administrator
                        // having full privileges to do anything.
                   Connection con = DriverManager.getConnection(url,"root", "birnExy");
                        //Display URL and connection information
                   System.out.println("URL: " + url);
                   System.out.println("Connection: " + con);
                        //Get a Statement object
                   stmt = con.createStatement();
                        //     Create the new database
                   stmt.executeUpdate("CREATE DATABASE JunkDB3");
                        //Register a new user named auser on the
                        // database named JunkDB with a password
                        // drowssap enabling several different
                        // privileges.
                   stmt.executeUpdate("GRANT SELECT,INSERT,UPDATE,DELETE," +"CREATE,DROP " +"ON JunkDB3.* TO 'nishant'@'localhost' " +"IDENTIFIED BY 'nishant';");
                   con.close();
         //}catch( Exception e ) {
              //     e.printStackTrace();
         //}//end catch
              //return hook;
         }//end main
    }//end class JDBCConnector
    gives the following error.....
    <soapenv:Envelope>
    &#8722;
         <soapenv:Body>
    &#8722;
         <soapenv:Fault>
    <faultcode>soapenv:Server.userException</faultcode>
    &#8722;
         <faultstring>
    java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
    </faultstring>
    &#8722;
         <detail>
    <ns1:hostname>SADMC0087</ns1:hostname>
    </detail>
    </soapenv:Fault>
    </soapenv:Body>
    </soapenv:Envelope>
    please help me

    20.05.2007 22:43:26 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
    INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Programme\Java\jdk1.5.0_05\jre\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\QuickTime\QTSystem\;C:\Programme\ATI Technologies\ATI Control Panel;C:\Programme\Java\jdk1.5.0_05\bin;C:\Programme\Apache Software Foundation\Tomcat 5.5\common\lib;
    20.05.2007 22:43:27 org.apache.coyote.http11.Http11BaseProtocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    20.05.2007 22:43:27 org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 1203 ms
    20.05.2007 22:43:27 org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    20.05.2007 22:43:27 org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/5.5.23
    20.05.2007 22:43:27 org.apache.catalina.core.StandardHost start
    INFO: XML validation disabled
    20.05.2007 22:43:28 org.apache.catalina.startup.HostConfig deployWAR
    INFO: Deploying web application archive SIpages.war
    20.05.2007 22:43:31 org.apache.coyote.http11.Http11BaseProtocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080
    20.05.2007 22:43:31 org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8009
    20.05.2007 22:43:31 org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/109 config=null
    20.05.2007 22:43:31 org.apache.catalina.storeconfig.StoreLoader load
    INFO: Find registry server-registry.xml at classpath resource
    20.05.2007 22:43:32 org.apache.catalina.startup.Catalina start
    INFO: Server startup in 4813 ms
    now this is when i run from eclipse where SIpages.war is my war file to be deployed...which looks something like this
    sipages/web-inf/classes
    sipages/web-inf/src
    sipages/web-inf/lib-this has the jar file as you mentioned
    and come other files...nwo where soes my .java file go in this war and how do i compile the java file

Maybe you are looking for

  • Mini-DVI to Video problem

    i got the mini-dvi to video adapter and hooked it all up with new video cables to my tv... it worked for a minute or two, then the image on my tv just started bouncing/cycling up and down really fast. i tried it on two other TVs and it was doing the

  • InDesign CS6 DPS click and Drag feature?

    Hi I was wondering if in inDesign CS6 it was possible to make a click and drag application. So when the application is playing on an ipad you can click and drag images around the screen freely?

  • Robocopy giving more files and folders at destination

    Hello all, Running Robocopy locally on a Windows 2008 R2 server. By local I mean the source and destination have local drive letters on the server. Its a file server server cluster and I am moving user files from one LUN drive to another. The issue i

  • Jdk1.4 Timer problem

    Hi all, I am using the Timer class provided with JDK1.4. During scheduling, you take the current time as the reference time for relative timer. Everything is ok if i dont change the system time. But consider this scenario. If i have a heartbeat timer

  • Minutes adding only on next month. Need it now.

    I had purchased a Malaysia 120minutes subscription and I had used up all the minutes. And then I purchased another Malaysia 120minutes but now the minutes are only adding up on the next month. I would like to use the minutes now instead of next month