Database connection with mysql

i have my server as follows:
import java.rmi.*;
public class JobServer
public static void main(String[] args)
try
JobImpl j = new JobImpl();
Naming.rebind("//"+"localhost"+"/JobImpl",j);
System.out.println("Registered");
catch (Exception e)
System.out.println("Exception occured in JobServer ... " +e);
and my interface implementation:
import java.rmi.*;
import java.rmi.server.*;
import java.sql.*;
public class JobImpl extends UnicastRemoteObject implements JobInt
String host="localhost";
String user="root";
String pass="admin";
String db="db";
String conn;
ResultSet rs;
Statement st;
public JobImpl() throws RemoteException
super();
try
Class.forName("com.mysql.jdbc.Driver");
conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user + "&password=" + pass;
Connection Conn = DriverManager.getConnection(conn);
st = Conn.createStatement();
catch (Exception e)
System.out.println("problem while establishing connection"+e);
public String getname(int jobno) throws RemoteException
try
rs = st.executeQuery("Select name from job whwre jobno="+jobno);
rs.next();
return(rs.getString("name"));
catch (Exception e)
e.printStackTrace();
return null;
when i 'javac JobServer' on the command prompt, i have the following error:
problem while establishing connection java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Exception occured in JobServer ... java.rmi.ConnectionException: Connection refused to host: localhost; nested exception is :
java.net.ConnectionException: Connection refused: connect
apparently theres a problem with my database connection... the connection isnt right? plz help

problem while establishing connection
java.lang.ClassNotFoundException:
com.mysql.jdbc.DriverSo fix that first. It's just a matter of installing the MySQL JAR file(s) in the appropriate place, i.e. somewhere on your CLASSPATH. Read their documentation.

Similar Messages

  • Create database connection with Mysql

    Hi, all:
    inside JDeveloper, i try to create a database connection for Mysql (third party
    JDBC driver). I input all needed parameters into
    JDeveloper database connection dialog, and test connection, the error message
    says 'Unable to find driver org.gjt.mm.mysql.Driver". The jar file contains driver
    is listed in system classpath, and Mysql and MM-Mysql JDBC driver are tested with
    other applications and there is no problem.
    So, what i should do to create such a connection ??
    Any help will be appreciated. thank you in advance.
    kevin.

    The connectio URL could look like this:
    (leave the User-, Password-, and Role-fields, in the tab before, empty)
    Java Class Name: org.gjt.mm.mysql.Driver
    URL: jdbc:mysql://localhost:3306/test?ultradevhack=true&?user=myuser&?password=mypassword

  • Slow database connection with mysql

    I am using MySQL Server 5.0 as my backend and java1.5 as my front end for the GUI. The following statements I use to connect to MYSql.
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    String url = "jdbc:mysql://localhost:3306/mysql";
    The database access seems to be very slow.
    I have a data file with about 3000 lines. The parser reads the file one line at a time, formats an insert query and calls executeUpdate. The process takes more than 2 minutes.
    What is slowing down my process? Please help
    Thanks

    I am using MySQL Server 5.0 as my backend and java1.5
    as my front end for the GUI. The following statements
    I use to connect to MYSql.
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    String url = "jdbc:mysql://localhost:3306/mysql";
    The database access seems to be very slow.
    I have a data file with about 3000 lines. The parser
    reads the file one line at a time, formats an insert
    query and calls executeUpdate. The process takes more
    than 2 minutes.
    What is slowing down my process? Please help
    ThanksHi,
    1. Are you opening and closing the database connection ,During inserting every record from data file?
    If so, please avoid opening closing connection for each query execution.
    Because , opening and closing the database connection is a time consuming one.
    You should open all the required database connections, before you use them or use
    Database connection pooling if your application is sucah a big one.
    2. Try PreparedStatment instead of Statement. Because Prepared statment query is
    compiled and stored into Cache. so if you are executing the same query again and again, the compiled query will be picked up from cache, by replacing with new
    parameters
    3. Check the logic you used to pick record from datafile and insert into database .
    4. Check your RAM size , if you installed database and jvm on same machine.
    if so , increase your RAM size.
    thanks,
    nvseenu

  • NetBean, I can't establish the oracle database connection with version 9i.

    In NetBean, I can't establish the oracle database connection with version 9i.
    I have create the datasource and it is fine.
    when i try to access the tables i get a message
    "Unable to refresh children, connection is broken, unsupported feature"
    in netbeans.
    Does netbeans support oracle 9i version.
    Thanks,
    VKK

    In NetBean, I can't establish the oracle database connection with version 9i.
    I have create the datasource and it is fine.
    when i try to access the tables i get a message
    "Unable to refresh children, connection is broken, unsupported feature"
    in netbeans.
    Does netbeans support oracle 9i version.
    Thanks,
    VKK

  • Mysql DataBase connectivity with PI 7.1

    Dear Experts,
            I need to connect Mysql DB table to access the data using PI 7.1 and pass it to ECC RFC.
    I have configured the sender JDBC channel details as below
    JDBC Driver : com.mysql.jdbc.Driver
    Connection : jdbc:mysql://<Server>:<port>/<database>
    But it showing the below error while starting my Sender channel in RWB.
    We already install the above driver  com.mysql.jdbc.Driver in PI again it shows the same error.
    Kindly help to resolve this issue.
    Best Regards,
    Monikandan

    Hi Monikandan,
    Looks like the driver installation was done properly. You need to check if the installation was proper and re-deploy with proper steps.
    Refer https://scn.sap.com/thread/400726.
    Regards,
    Lavanya R

  • Jdbc connectivity with mysql database

    I created a database in mysql, but I have problems communicating with the DB in java 
    here is the error
    java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/books
    at java.sql.DriverManager.getConnection(DriverManager.java:604)
    at java.sql.DriverManager.getConnection(DriverManager.java:221)
    at displayauthors.DisplayAuthors.main(DisplayAuthors.java:30)
    java.lang.NullPointerException
    at displayauthors.DisplayAuthors.main(DisplayAuthors.java:66)
    BUILD SUCCESSFUL (total time: 1 second)
    I edited the system variables in windowds
    CLASSPATH
    .;C:\Program Files (x86)\Java\jre7\lib\ext\QTJava.zip
    CLASSPATH1 (notice the 1 at the end, I don't want to override the previous one
    .,C:\Program Files (x86)\MySQL\Connector J 5.1.30\mysql-connector-java-5.1.30-bin.jar
    The Hostname: localhost   Port: 3306
    Username: root
    password:   Tpswsd77? (changed for thios post)
    Stored Connection: Local instance MySQL56
    connection Method: Standard(TCP/IP)
    HERE IS THE CODE 
    public class DisplayAuthors {
    // database URL                             
       static final String DATABASE_URL = "jdbc:mysql://localhost:3306/books";
       // launch the application
       public static void main( String args[] )
          Connection connection = null; // manages connection
          Statement statement = null; // query statement
          ResultSet resultSet = null; // manages results
          // connect to database books and query database
          try
            // establish connection to database                             
             connection = DriverManager.getConnection(
               // DATABASE_URL, "deitel", "deitel" );
                     //<editor-fold defaultstate="collapsed" desc="comment">
                     DATABASE_URL, "root", "Tpswsd77?" );
             //</editor-fold>
                  // create Statement for querying database
             statement = connection.createStatement();
             // query database                                       
             resultSet = statement.executeQuery(           
                "SELECT authorID, firstName, lastName FROM authors" );
             // process query results
             ResultSetMetaData metaData = resultSet.getMetaData();
             int numberOfColumns = metaData.getColumnCount();    
             System.out.println( "Authors Table of Books Database:\n" );
             for ( int i = 1; i <= numberOfColumns; i++ )
                System.out.printf( "%-8s\t", metaData.getColumnName( i ) );
             System.out.println();
             while ( resultSet.next() )
                for ( int i = 1; i <= numberOfColumns; i++ )
                   System.out.printf( "%-8s\t", resultSet.getObject( i ) );
                System.out.println();
             } // end while
          }  // end try
          catch ( SQLException sqlException )                               
             sqlException.printStackTrace();
          } // end catch                                                    
          finally // ensure resultSet, statement and connection are closed
             try                                                       
                resultSet.close();                                     
                statement.close();                                     
                connection.close();                                    
             } // end try                                              
             catch ( Exception exception )                             
                exception.printStackTrace();                           
             } // end catch                                            
          } // end finally                                             
       } // end main
    } // end class DisplayAuthors

    I edited the system variables in windowds
    CLASSPATH
    .;C:\Program Files (x86)\Java\jre7\lib\ext\QTJava.zip
    CLASSPATH1 (notice the 1 at the end, I don't want to override the previous one
    .,C:\Program Files (x86)\MySQL\Connector J 5.1.30\mysql-connector-java-5.1.30-bin.jar
    A few facts:
    1. You NEED to have the JDBC driver jar on the Java classpath
    2. You don't NEED to have the jar on the Windows classpath
    3. You don't NEED to 'override' the Windows classpath - you can just append the JDBC jar to it
    Just use #3 above - edit the Windows CLASSPATH environment variable and add the JDBC jar to it. At it at the start and follow it with a semicolon. Or at it at the end AFTER adding a semicolon.
    Or specify the CLASSPATH on the command line when you launch Java. Use the '-cp' or '-classpath <class . . >' options. Just type 'java' at the command line to see the list of parameters that can be used.

  • Mysql database connection with Labwindows/CVI 2009 sql toolkit

    Dear experienced users,
    I am using the following software/hardware:
    Windows 7/ Mysql database 5.6.15 64-bit with MySql ODBC 5.2 Ansi driver installed
    Labwindows/CVI 2009 with sql toolkit
    The user DSN of ODBC Data source administrator have been confiugred to one of mysql database. The test MYSQL Connector/ODBC is succesful.
    The Labwindows/CVI build setting is configure to debug64 after trying debug (32)
    The source code is from the example readtab.c with changes to the dsn I am testing
        hdbc = DBConnect ("DSN=dvd_collection");   
    The error message I have is confusing me.
    (it is in the attachd png)
    I thought it was due to the 64 bit mysql database. That's why I tried the 64 bit build from Labwiondws/CVI. I alsow tried Labview DB tools open connect.vi. It shows me the same error.
    Any suggestion is appreciated.
    Thanks,
    Jimmy
    Attachments:
    Capture.PNG ‏24 KB

    Jimmy
    I always use connection strings of the form "DSN=datasourcename;UID=database_user_id; PWD=database_user_password".
    Where:
    datasourcename = The name of the connection defined in the ODBC connection.
    database_user_id = One of the user identities created by the database administrator. Obviously the administrator will lock down the permissions appropriate to the task in hand.
    database_user_password = The password that identifies database_user_id, again set by the database administrator.
    Note that while it is obviously desireable to lock the permissions down as far as possible on the MySQL server, the more you do so, the slower the database will run, because of the way mySQL searches the permissions tables.

  • Cannot establish mysql database connection with j2ee application

    Hello All,
    I started studying J2EE technology about a month back. I have this simple application involving a couple of servlets and jsps. The code is from a reliable source , so I know that there is nothing wrong with the prog code. Now the code uses a simple database, where I am stuck! I just can't connect to the database Mysql.
    I downloaded Mysql database from the mysql site.
    I downloaded JDBC driver for mysql from the same site.
    Can somebody please tell me which files(from the driver that I downloaded) have to be unzipped to jar files to be set in the class location?
    Any help is highly appreciated.
    Thanks
    Starting WithJ2EE

    Hello All,
    I started studying J2EE technology about a month back. I have this simple application involving a couple of servlets and jsps. The code is from a reliable source , so I know that there is nothing wrong with the prog code. Now the code uses a simple database, where I am stuck! I just can't connect to the database Mysql.
    I downloaded Mysql database from the mysql site.
    I downloaded JDBC driver for mysql from the same site.
    Can somebody please tell me which files(from the driver that I downloaded) have to be unzipped to jar files to be set in the class location?
    Any help is highly appreciated.
    Thanks
    Starting WithJ2EE

  • Problem in establishing connection with mysql 5.0

    Hi,
    I am using JCAPS 5.1. I tried to insert data to mysql database table.
    But i got following error
    java.sql.SQLException: Error in allocating a connection. Cause:
    Physical Connection doesn't exist.
    My intention is to read file in which data are comma seperated and to
    populate those values to a mysql 5.0 database table.
    Sample DATA in file [test.txt]
    111,gg,23,MFG
    112,hh,24,MFG
    113,ii,25,RETAIL
    114,jj,26,IT
    Database table: employee
    eno,ename,eage,edept
    While creating JDBC OTD there is no problem in establishing connection with database. But after deploying i got above error.
    I have used Mysql 5.0 Connector/J JDBC driver. Added JDBC driver jar files to following directories as required.
    1) C:\JavaCAPS51\logicalhost\is\lib
    2)C:\JavaCAPS51\logicalhost\is\domains\test\lib
    Steps i have followed as per JDBC-ODBC -eway user guide doc.
    1) Created USerDefined OTD and added necessary fields
    2) Created JDBC OTD.
    3) Created JAVA collaboration and do business process for inserting
    4) Mapped all components by creating in Connectivity MAp
    5) created necessary external systems in envrionment explorer.[JDBC External System and File External System]
    6)Created Deployment profile
    5) Deployed it.
    After deploying it gives error as
    java.sql.SQLException: Error in allocating a connection. Cause: Physical Connection doesn't exist
    Please let me know the solution for problem.
    Message was edited by:
    VenkateshSampoornam

    In the environment definition,
    -> External Application JDBC
    -> Properties
    -> Outbound JDBC Connection
    You have the database URL in the "DriverProperties" field
    Valid URL would be : jdbc:mysql://localhost:3306/caps
    !! The doc says that this field is optional !! Seems to be an error in the doc:
    Hope this helps
    Seb

  • Database synchronization with MySQL

    Hi,
    I'm connecting my ADFbc to a MySQL database v5.6; However, I can't seem to find the option that allows me to synchronize my entities to the changes made on the database tables. I am using JDeveloper 12c.
    Is the database synchronization option only available for an Oracle database connection?
    Imad.

    Imad,
    database synchronization is available.
    Zeeshan Baig's Blog: Connecting MySQL Database with Jdeveloper 11g
    Is your project migrated from a older jdev version ?

  • Connecting with mysql

    hello
    how can i create a connection to mysql and postgresql databases in jdbc. without using odbc.
    thanks.

    You need to use a different driver. I assume you're using the jdbc-odbc bridge driver.
    For mysql, get the mm.mysql driver at http://mmmysql.sourceforge.net/
    For postgresql, go to http://jdbc.postgresql.org/
    I've only used the mysql driver, so I don't know the details of how to use the postgresql one.
    In general, you will have to do the following:
    1. download the jar file and put it in your classpath
    2. change the connection url string to conform with the format in the driver documentation.

  • Jar file connection with mysql

    Hello everyone i ve a problem if you people could solve please help...
    When i compile my java code with mysql connection it works perfectly, but when i convert into jar file its not updating any values in the mysql database
    Can anyone tell me a solution.

    subhavenkatesh wrote:
    Can anyone tell me a solution.You have a bug. Find it. Fix it.

  • External connection with MYSQL db

    Hi to all,
    i need to make an external connection to MYSQL database with "EXEC SQL" instruction of abap/4.
    I've already maintained the DBCON table: i've created a new external connection (called TEST1), but i don't really know how to valorize the DBMS (db type) and CON_ENV (connection instructions) fields .
    For MSSQL is simple (there are many examples on this forum), but for MYSQL db?? I wasn't able to find posts about configuring it.
    Is there this kind of connection possible. What are other "way" to make this connection? I'd like to select/insert/update some table rows
    Helpfull answer will surely good rewarded
    Thx a lot in Advice
    Andrea Galluccio

    Hi
    For MSSQL , we give the Connection Information as just MSSQL_SERVER=<ServerName>. But for MYSQL and oracle the parameters differ.
    Just check out http://www.irietools.com/iriepascal/progref125.html
    I am not quite sure abt it.

  • Java connection with mysql

    Anybody please help me:
    I creating java application that comunicate with the mysql database. I use JConnector and all work find.
    My problem is when i compile the program into JAR file and when i run it(double click the file), i saw my application but the connection with the mysql database is not successfull. i try to search from internet, and i found that i must put my JConnector inside the jdk1.3.1/jre/lib/ext.
    Once i put that the program can run and the connection is fine, but only if i run it from the dos by typing the command c:\java -jar turkeySystem.jar.
    So anybody can advise me, what should i do if i want to make my application run smoothly and connected with the database, without having the dos run at the background. (just double click the jar file).
    i don't have problem to run that if i using ms access as a database.
    Thank you in advanced.

    if it runs with "java -jar turkeySystem.jar." you have a valid manifest.mf in your jar. so it can basically be executed by double clicking it --- if the JDK is installed correctly. otherwise you need to change the datatype handling in windows by adding "java -jar %1" as the command for the file suffix ".jar". this is the case if you e.g. just copy your Java SDK folder to a computer and didn't install it with the windows exe java wizard.

  • Connection with MYSQL ODBC

    Post Author: wrkwinter
    CA Forum: Data Connectivity and SQL
    Hi,   I am having problem with conecting Crystal Report XI to the MYSQL Server. I am using Mysql Connector/ODBC 3.51. I configured ODBC connection . Once i connect to MYSQL server thru Crystal Rpeort Everything works fine but after 5-10 minutes if i refresh the report I get following error.
    "Failed to retrieve data from the database"DetailsHY000:&#91;MySQL&#93;&#91;ODBC 3.51 driver&#93;&#91;mysqld-4.1.22-standard-log&#93;&#91;MySQl server has gone away&#91;Database vendor code :2006&#93; and if i log off and relog on to database everything works fine like for another 5-10 minutes and after that same ERROR  But if i use MYSQL Query Browser to connect to the database. I don't have any problem like that.  Can please explain any reason for that.....Thanks

    Post Author: synapsevampire
    CA Forum: Data Connectivity and SQL
    Check out:
    http://www.mysqltalk.org/server-has-gone-away-vt158777.html
    I'd guess that you're timing out or exceeding the number of connections.
    -k

Maybe you are looking for

  • Here We Go Again :p

    At first, a simple restart fixed this. Now, it does it all of the time and my camera is unusable. It's not just Photo Booth anymore, either. Is it hardware or software issue? Is it a do-it-yourself fix or an Apple genius fix?

  • Photoshop CS3 Extended CD

    I had Photoshop installed on my pc with a cd. Unfortunately I had to have a repair a reinstall of Windows xp. Now the CD will not work it does not install the programme. I have contacted Adobe they say its not a valid serial number. and most certainl

  • Java mapping to validate XML

    Hi Im trying to use the code from http://help.sap.com/saphelp_nw04/helpdata/en/c4/e1343e8c7f6329e10000000a114084/frameset.htm to create a java mapping that validates a Xml message from XI, according to xsd resources inside my jar package. The problem

  • FCS Upgrade Serial Number?

    I recently bought a set of upgrade disks for Final Cut Studio 2 on eBay. Completely original Apple-manufactured disks in an Apple box. But no upgrade serial number. The seller insisted that the upgrade installation would proceed from the existing FCS

  • Essbase and MS-SQL on same server

    My organization is attemtping to consolidate servers, and to that end we would like to run MS-SQL 2000 as well as Essbase Analytic Server and Essbase Admin Server on the same Win2000 server.Does anyone know of any problems with this setup -- beyond t