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.

Similar Messages

  • Jar file connection to mysql

    im writing i database front end using eclipse
    when i run the code it works fine and connects to the database
    but when i make a jar file from the project it doesnt connect to mysql

    i think i set it to use the class files not the
    source codehuh?
    I meant what have you done with the driver jars
    i dont get an exception it just doesnt connectOr probably you don't know how to see it on a console...

  • How to run jar file created with higher version on lower version ?

    Hi,
    I downloaded a jar file and trying to run it on Linux machine with Java version 1.4...
    I got error that jar file complied with 1.5 version.
    Is there any way to run it on 1.4 version. I don't want to upgrade Java version of my linux :)
    Regards,
    Ajay

    EJP wrote:
    On the contrary, the 'reality' is that it is better, and probably easier, once you analyse and present the comparative costs and risks correctly, to get the mandate lifted than to back-port code to platform levels for which it was not designed.The main blockade (judging by my observations) for actually doing it is that this is not a simple code change, which is what programmers really, really, really want to keep it within their comfort zone. All of a sudden you're tasked with software upgrades and the demands that it brings, such as testing to make sure everything still works properly and getting grumpy system's administrators to actually go do it.
    I wouldn't be surprised that there are people out there that would rather back port a library than to take the initiative to get Java upgraded :/

  • Jar file and remote mysql connect

    I have a jar file that i want anyone run it.The problem is that the code makes a connection to a database (mysql) to my computer.How anyone can connect to my databse in my computer from another pc without the user have to had the java \ mysql connect or hte mysql.Only the java.I try with a jnlp file and the jar file stored in my computer.I have a host name and i have open the port 3306 for mysql and allow remote connections to mysql.Can you help me;;

    ok i connect to database like this:
    try {
                   String userName = "username";
                   String password = "password";
                   String url = "jdbc:mysql://HOSTNAME/bankloans";
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
                   conn = DriverManager.getConnection(url, userName, password);
              } catch (Exception e) {
                   System.out.prinln(e);
              }The JNPL file
    <?xml version="1.0" encoding="Windows-1251"?>
    <jnlp
      spec="1.0+"
      codebase="http://nasikas.ath.cx:8080/bankloans/"
      href="BankLoans.jnlp">
    <information>
    <title>Bank Loans Programme</title>
    <vendor>Softlets</vendor>
    <description>Bank Loans Programme</description>
    <offline-allowed/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.6+"/>
    <jar href="BankLoans.jar" main="true"/>
    <jar href="mysql-connector-java-5.1.0-bin.jar"/>
    </resources>
    <application-desc main-class="Go"/>
    </jnlp>What is wrong;;

  • 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

  • Create a simple connection with mysql

    hello
    my name is edvanio i am from brazil.
    i'd like to connect one program in Java with mysql for insert, delete and update one simple base ex. teste with nome and fone.
    thank , bye

    here's a couple of sites
    http://www.javacoding.net/articles/technical/java-mysql.html
    http://www.developer.com/java/data/article.php/3417381
    I recently installed MySQL (just to see if I could get a working program to run)
    these were the steps
    1. downloaded MySQL
    2. downloaded the connector file
    3. unzipped/installed MySQL
    4. unzipped the connector file
    mysql-connector-java-3.0.17-ga-bin.jar
    copied the jar file into this directory
    C:\Program Files\Java\jdk1.5.0_03\jre\lib\ext
    5. opened MySQL, using the code from Gamelan
    create the db JunkDB
    created the user, permissions, password
    6. combined the code from both sites (code follows)
    and it worked OK
    import java.sql.*;
    class MySQL_Test
      public MySQL_Test() throws Exception
        testDriver();
        Connection con = getConnection();
        executeUpdate(con,"CREATE TABLE test(id int,text varchar(20))");
        executeUpdate(con,"insert into test(id,text) values (1,'first entry')");
        executeUpdate(con,"insert into test(id,text) values (2,'second entry')");
        executeUpdate(con,"insert into test(id,text) values (3,'third entry')");
        executeQuery(con,"select * from test");
        executeUpdate(con,"drop table test");
        con.close();
      protected void testDriver() throws Exception
        try
          Class.forName("com.mysql.jdbc.Driver");
          System.out.println("MySQL Driver found");
        catch(ClassNotFoundException cnfe)
          System.out.println("OOPs - MySQL Driver nowhere to be found");
          throw (cnfe);
      protected Connection getConnection() throws Exception
        String url = "";
        try
          url = "jdbc:mysql://localhost:3306/JunkDB";
          Connection con = DriverManager.getConnection(url,"auser","drowssap");
          System.out.println("Connection OK");
          return con;
        catch(SQLException sqle)
          System.out.println("OOPs - No Connection");
          throw (sqle);
      protected void executeUpdate(Connection con,String sqlStatement) throws Exception
        try
          Statement s = con.createStatement();
          s.execute(sqlStatement);
          s.close();
        catch(SQLException sqle)
          System.out.println("OOPs - error executing statement");
          throw (sqle);
      protected void executeQuery(Connection con,String sqlStatement) throws Exception
        try
          Statement s = con.createStatement();
          ResultSet rs = s.executeQuery(sqlStatement);
          while(rs.next())
            String id = (rs.getObject("id").toString());
            String text = (rs.getObject("text").toString());
            System.out.println("Found record "+id+" "+text);
          rs.close();
        catch(SQLException sqle)
          System.out.println("OOPs - error executing resultset");
          throw (sqle);
      public static void main(String[] args)
        try
          new MySQL_Test();
        catch(Exception e){e.printStackTrace();}
    }

  • 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

  • How connect with mysql 5

    hi master
    sir i am use studio creator now i install the mysql5
    sir please give me idea how i connect my studio creator with mysql 5
    thank
    aamir

    hi
    follow the following steps:
    1) Download Jconnector Driver for java from www.mysql.com
    2) Open the creator , from servers palette select data source and right click.
    3) choose new data source , click new
    4) select the jar file u downloaded from the web site.
    5)clicj suggeste ( this will make the creator to select connections statments automatailcly )
    6) put the username and password and click ok
    this will make a datasource with mysql server.
    be sure that the mysql server is run,, and make sure that u apply right username and password
    Hope this will help
    Good luck
    Mohammed

  • 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.

  • Problem with USERNAME & PASSWORD creation--JDBC connection with MYSQL

    How to connect to JDBC with Mysql Connector
    i installed mysql & created table, it works fine
    During Password---> I gave it as tiger , no username
    i installed mysql connector
    i saved the .jar file path in class path
    HOW TO CREATE USERNAME & PASSWORD & DATASOURCE NAME ---> Is it the password -tiger or something else like (ADMinstrative tools-ODBC-services--etc )
    Pl, help,
    tks
    Xx

    How to connect to JDBC with Mysql Connector
    i installed mysql & created table, it works fine
    During Password---> I gave it as tiger , no usernameTiger? This ain't Oracle.
    I think you should give a username and password. How can it look up a password without a username? Better GRANT the right permissions, too.
    Read the MySQL docs a bit more closely. Your path isn't the way to go.
    %

  • Jakarta-tomcat-3.3.2 connection with mysql-4.1.12a-win32

    how do i connect to mysql using tomcat?
    i've set the class path = ".;D:\j2sdk1.4.2_08\jre\lib\ext\mysql-connector-java-3.1.10-bin.jar;"
    without quotes
    i've copy the mysql-connector-java mysql-connector-java-3.1.10-bin.jar into the mentioned directory = "D:\j2sdk1.4.2_08\jre\lib\ext\"
    and my computer's mysql 's service is starting since my computer restart [i've checked it by right click desktop toolbar->Task Manager->Processes->mysqld-nt.exe..
    and i've used the code from :
    http://www.stardeveloper.com/articles/display.html?article=2003090201&page=4
    to test if my connection is active, my JdbcExample1.java file is located at D:\jakarta-tomcat-3.3.2\webapps\ROOT\WEB-INF\classes\com\example, so my source code is :
    package com.example;
    import java.sql.*;
    public class JdbcExample1 {
      public static void main(String args[]) {
    Connection con = null;
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql:///test", "root", "nothing");
    if(!con.isClosed())
    System.out.println("Successfully connected to MySQL server...");
    } catch(Exception e) {
    System.err.println("Exception: " + e.getMessage());
    } finally {
    try {
    if(con != null)
    con.close();
    } catch(SQLException e) {}
    when i compile the file using javac, it's fine, when i run it using java, it shows me this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: JdbcExample1 (wrong n
    ame: com/example/JdbcExample1)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    3)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    what have i missed out? anyone can u please help me? is my coding or setting in-accurate? thanks for reviewing my topics too

    I'm not sure why you have mentioned Tomcat, but you need to run the class with something like:
    java -classpath .;D:\j2sdk1.4.2_08\jre\lib\ext\mysql-connector-java-3.1.10-bin.jar com.example.JdbcExample1If you've correctly set the CLASSPATH environment variable then you can leave out the -classpath command line argument. Notice that you must specify the package of the class too.
    To compile this all correctly, you should do something like:
    mkdir classes
    javac -d classes JdbcExample1.javaand then run with
    java -classpath classes;D:\j2sdk1.4.2_08\jre\lib\ext\mysql-connector-java-3.1.10-bin.jar com.example.JdbcExample1

  • 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.

  • 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.

  • Deploying an application with existing library as jar file created with ANT

    Hello All,
    I am having some trouble with a web application I am deploying to Tomcat. I have an custom library that works perfectly as a jar file included in the lib directory if I include all the jars that that library depends on into the lib directory also. What I would like to do is bundle the required jar files into my libraries jar file, but it failes to work when I do that.
    Any thoughts? Does Tomcat prevent this?
    I am using ANT to create my jar file, but when I look at the contents of my jar file it includes all the requested directories.
    My build.xml looks like this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <project name="myapp" basedir="." default="jar">
    <property name="classes.dir" value="./classes"/>
    <property name="jar.dir" value="."/>
    <property name="java_lib.dir" value="../../../../../Program Files/Java/lib"/>
    <target name="jar">
    <jar destfile="${jar.dir}/${ant.project.name}.jar">
    <fileset dir="classes"/>
    <fileset dir="${java_lib.dir}" includes="jai_codec.jar.jar"/>
    <fileset dir="${java_lib.dir}" includes="xercesImpl.jar"/>
    <fileset dir="${java_lib.dir}" includes="mysql-connector-java-3.1.8-bin.jar"/>
    <fileset dir="${java_lib.dir}" includes="xmlParserAPIs.jar"/>
    <fileset dir="${java_lib.dir}" includes="mlibwrapper_jai.jar"/>
    <fileset dir="${java_lib.dir}" includes="xml-apis.jar"/>
    <fileset dir="${java_lib.dir}" includes="jai_core.jar"/>
    </jar>
    </target>
    <target name="run" depends="jar">
    <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/>
    </target>
    <target name="clean-build" depends="jar"/>
    <target name="main" depends="run"/>
    </project>
    Like I said...it includes these jar files in my jar file, but will not function properly with my tomcat app. If I exclude these jar files and include them seperately then everything works.
    NOTE: I do not access any of these libraries directly from any servlets, only from my classes.
    Thanks,
    J-Rod

    This probably isn't posted on the correct forum. This JVM forum is for discussing issues related to running java in an Oracle database using the OJVM, Oracle's embedded java VM. Possibly you are trying to use OJVM through JDEV but that isn't clear from your post and I don't believe that the error you are reporting would occur in that case. If it did or if you are in fact trying to run client java via JDEV the problem would be a JDEV rather than OJVM issue and so the JDEV forum,
    JDeveloper and ADF
    is the correct one to use.

  • 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

Maybe you are looking for

  • Time Capsule & Airport Express Extended Network loses connection!

    OK, so I am an Apple virgin of 2 months experience, after many many years with Windows based PCs, so please be patient and gentle with me. Sorry about the long explanation..... My set-up comprises of a Time Capsule, which is connected to the Internet

  • How to use CSS and images in a plsql-dbms_output reports?

    Hi. Windows 2000 SP4 SQL Developer 1.2.1.32.13 Java 1.5.0_07 Oracle 9.2.0.6 I'm trying to create a plsql-dbms_output report with HTML that uses a stylesheet (CSS) and an image. These seem to be ignored by the report viewer. The following example work

  • Throw or motion path

    new to motion. import object and drag behaviors to it, such as throw, and the box will move but the object(pic in this case) disappears. how do i get the entire image to move with the box??? thanks

  • Oracle text performance

    hi all. i have useing orcle text for the indexing purposes .. the below query goes for an wildcard search and it performance is very poor .. /* Formatted on 2009/08/11 16:06 (Formatter Plus v4.8.5) */ SELECT *   FROM (SELECT z.*, ROWNUM r           F

  • When defining a new payroll

    when defining a new payroll , In the Date Offset section, enter the following: Normal Payment: -2 BACS Processing: -2 Pay Advice: -2 Cut Off: -7 what do these values mean in a Monthly payroll...?