Java DB or MySQL

hi!
iam complete new to databases and now i wonder whats the difference between java DB that i can use in Netbeans IDE and MySQL..
whats the advantage and disadvantage between this two?
sry for my bad english..
//Matt

duffymo wrote:
More accurately, Java DB (same code base as Derby) is part of the JDK 6 download, not the Java SE spec or the JRE 6 download.So if you download the JDK 6, develop an app using Derby, and then deploy it you won't have use of Derby from the JRE? That's what you imply when you say "not...JRE 6 download". Yes, that is true. It's only in the JDK. You still have to think about deployment.
http://weblogs.java.net/blog/forsini/archive/2006/06/java_db_is_now.html
http://www.artima.com/forums/flat.jsp?forum=276&thread=173456
If true, not very useful.Depends on the eye of the beholder, I guess... It was a controversial thing to do, no doubt about that.
http://java.net/pub/pq/109
http://www.theserverside.com/news/thread.tss?thread_id=40967

Similar Messages

  • Java Connector via MySQL [ Cannot Connect ]

    I downloaded the MySql connector and extracted the connector and placed it at this directory,
    C:\Program Files\Java\jdk1.5.0_06\jre\lib\ext
    I also set the classpath as such by adding
    ClassPath = .;C:\Program Files\Java\jdk1.5.0_06\jre\lib\ext\mysql-connector-java-3.1.12-bin.jar.Actually , I followed the tutorial at
    http://www.stardeveloper.com/articles/display.html?article=2003090201&page=4.
    I then executed this program below.
    import java.sql.*;
    public class Connect {
      public static void main(String args[]) {
        Connection con = null;
        try {
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         con = DriverManager.getConnection("jdbc:mysql:///enron", "root", "horizon");
          if(!con.isClosed())
            System.out.println("Successfully connected to MySQL server...");
        } catch(Exception e) {
          System.err.println("Captured Exception: " + e.getMessage());
        } finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
    However i was unable to connect..This is wat happened as below..
    C:\>java Connect
    Captured Exception: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.net.UnknownHostException
    MESSAGE: localhost: localhost
    STACKTRACE:
    java.net.UnknownHostException: localhost: localhost
            at java.net.InetAddress.getAllByName0(Unknown Source)
            at java.net.InetAddress.getAllByName0(Unknown Source)
            at java.net.InetAddress.getAllByName(Unknown Source)
            at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:137)
            at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
            at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
            at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
            at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at Connect.main(Connect.java:7)
    ** END NESTED EXCEPTION **
    Last packet sent to the server was 31 ms ago.
    Any Help watsoever is greatly appreciated.
    Thanks in advance.
    Cheers.

    Hi thanks for the reply.
    Although , I am though a bit baffled by your reply.
    Where is it that you want me to add the URL.Not add the URL - change the one you have. Read the docs for the connector and follow that.
    And where else should i place that jar file.I put it in my CLASSPATH, close to where the source for my project is. (That means not in one place, but several places. I duplicate the JAR file for every app that needs it.)
    Cos I follow the tutorial at...
    http://www.stardeveloper.com/articles/display.html?art
    icle=2003090201&page=4.
    Unless You are saying that the above site is wrong..
    If thats the case, can you point out another
    alternative site which can guide me along .No time to read that site, nor do I have the interest.
    The Sun Java tutorial is sufficient for using JDBC. As far as how you package and deploy apps, that's another matter. You should be using the class name and URL that your JDBC driver docs suggest.
    %

  • Java classes and MySql Files

    Hello,
    There is a way to distribute the Mysql db files with yout java application without need to install Mysql in the computer, like in access, you just copy the .mdb file with your java class and create a conection to it.
    Thank You

    No. If you want to do that you should just use Access. mySQL files will not work without the mySQL server.

  • Java feat database(MySql)

    I am trying to write a single-client/server application which maintains a database. The client app sends request to server which executes the request and returns the result to the client. The GUI on the client side must be able manipulate the database by: creating tables, load tables with the serialized files, insert data, delete data, manipulate Booleans’ and do calculations.
    Question 1: In my class how do I initialize the Boolean? Referring to the text book (JAVA Sixth Edition) Chapter 14, I created the class and a different class with the same info except for the import of the Serializable class/(function) in a package that I created. Both classes are in there.
    Problem 1: How do I declare the default constructor of a Boolean? For numeric and string value it seems easy e.g.:
    public class Serializable()
    this(0," "," ",0.0);
    But for a Boolean?
    public class Serializable()
    this(" "," ", ?); - >string, string, Boolean
    I have made compensation for handling a ClassNotFoundException, but that error message is about all it gives me. Where did I go wrong????
    Problem 2:How do I code the other functionalities? The book only talks about viewing information from the database, nothing about creating and loading tables
    let alone insert and delete.
    It does talk about a script that is on the CD to create the tables in MySql, but I don't have the CD. Can I use such a script in my client app?
    Are there some examples of such applications on the net or are there scripts I can refer to, that might help me?
    Please help :-{
    Thanx
    Sgt

    This is what my record is suppose to look like:
    package DvdPackage;
    import java.io.Serializable;
    public class Movies implements Serializable
    private String title;
    private String category;
    private boolean newRelease;
    private boolean availableForRent;
    public Movies()
    this("","",true,true);
    public Movies(String Title, String Cat, boolean New, boolean Avail)
    setTitle(Title);
    setCategory(Cat);
    setRelease(New);
    setAvailable(Avail);
    // set methods
    public void setTitle(String Title)
    title = Title;
    public void setCategory(String Cat)
    category = Cat;
    public void setRelease(boolean New)
    newRelease = New;
    public void setAvailable(boolean Avail)
    availableForRent = Avail;
    //get methods
    public String getTitle()
    return title;
    public String getCat()
    return category;
    //checks if the movie is a new release
    public boolean getNew()
    return newRelease;
    //checks if the movie is available
    public boolean getAvail()
    return availableForRent;
    The reading a serialized class looks like this:
    import java.io.*;
    import DvdPackage.Movies;
    public class ReadingFiles
    private ObjectInputStream input;
    public void openFile()
    try
    input = new ObjectInputStream(new FileInputStream("Movies.ser"));
    catch(IOException ioException)
    System.err.println("Error opening the files.");
    public void readRecords()
    Movies record;
    //System.out.printf("%-40%-40%-10s%10\n", "Title", "Category","New Release","Available");
    try
    while(true)
    record = (Movies) input.readObject();
    System.out.printf("%-20%-20%-1s%1\n",
    record.getTitle(),
    record.getCat(),
    record.getNew(),
    record.getAvail());
    catch(EOFException eofException)
    return;
    catch(ClassNotFoundException classNotFound)
    System.out.println("Unable to create object.");
    catch(IOException ioException)
    System.out.println("Error during the read of the Movies file!!!!");
    public void closeFile()
    try
    if(input != null)
    input.close();
    catch(IOException ioException)
    System.err.println("Error closing movie File!!!!");
    System.exit(1);
    The code runs with no errors, but it stops at the "ClassNotFound" handler.
    What is wrong with my code?

  • Java connect to mysql

    hi,im new user here.....im also a new java user.......i've just learn how to connect java with mysql,so i download the driver MySQL Connector/J 5.0
    after that,i mport the library to JBulider X.then i got error with my script.
    package database;
    import java.sql.*;
    public class Mysql {
    public static void main(String[] args) {
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    catch (Exception e){
    System.err.println("Error Loading driver :" + e.getMessage());
    and then the error are :
    java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:141)
         at database.Mysql.main(Mysql.java:19)
    Exception in thread "main"
    What is that meant ?please someone help me...i need a quick reply......thanxxxsss....

    hello,all.........i just connected to the driver,but now another error come out
    Error SQL Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.net.SocketException
    MESSAGE: java.net.ConnectException: Connection refused: connect
    STACKTRACE:
    java.net.SocketException: java.net.ConnectException: Connection refused: connect
         at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
         at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
         at com.mysql.jdbc.Connection.createNewIO(Connection.java:2592)
         at com.mysql.jdbc.Connection.<init>(Connection.java:1509)
         at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
         at java.sql.DriverManager.getConnection(DriverManager.java:512)
         at java.sql.DriverManager.getConnection(DriverManager.java:193)
         at database.Mysql.main(Mysql.java:28)
    ** END NESTED EXCEPTION **
    wat is that mean ?
    this is my script
    package database;
    import java.sql.*;
    public class Mysql {
    public static void main(String[] args) {
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    try {
    System.out.println("Loading drivers........");
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    System.out.println("Driver loaded !");
    catch (Exception e){
    System.err.println("Error Loading driver :" + e.getMessage());
    try {
    con = DriverManager.getConnection("jdbc:mysql://localhost/test_db?user=test_admin&password=1234");
    stmt = con.createStatement();
    rs = stmt.executeQuery("select * from `stock`");
    ResultSetMetaData rsmd = rs.getMetaData();
    int nColumn = rsmd.getColumnCount();
    for(int i=1;i<=nColumn;i++){
    System.out.print(rsmd.getColumnName(i) + " | ");
    System.out.print("\n");
    /*while(rs.next()){
    System.out.println(rs.getLong(1) + "\t" + rs.getString(2) + "\t" + rs.getLong(3) + "\t" + rs.getString(4) + "\t"
    + rs.getDouble("price") + "\t" + rs.getInt("supplier") + "\t" + rs.getDate("buy_date"));
    rs.close();
    stmt.close();
    con.close();
    catch (SQLException e){
    System.err.println("Error SQL " + e.getMessage());

  • Java datatype for MySQL DATE?

    Hello!
    I want to read the content of a database table and store it in a linked list.
    My problem is that i dont know what datatype in Java to use for storing the MySQL type DATE.
    Can i use different types for that purpose? Which type is best?
    Thank you

    mattias_westerberg wrote:
    Hello!
    I want to read the content of a database table and store it in a linked list.
    My problem is that i dont know what datatype in Java to use for storing the MySQL type DATE.
    Can i use different types for that purpose? Which type is best?
    Thank you[java.sql.Date|http://java.sun.com/javase/6/docs/api/java/sql/Date.html]
    The best way to store it depends on what you want to do with it. Ultimately you could store it however you wish: bytes, a string, serialized to disk somehow, but a java.sql.Date is what your JDBC API will be taking so it would be convenient to use that if you want to modify the date and store it back to the database.

  • New to java connection with MySQL

    hello people,
    I have downloaded 'mysql-connector-java-5.0.3' and I have unzipped it in my E directory. I am using notepad to edit java. How should I set the Class path and make the connection . Please help
    Thanks in adance
    Kris

    after executing the following code
    import java.sql.*;
    public class conntest
         static Connection conn;
         public conntest()
         public static void main(String args[])
              try
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
                   conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/kris?user=root");
              catch(Exception ex)
                   System.out.print("error"+ex.getMessage());
              try{
                   Statement s = conn.createStatement();
                         ResultSet rs = s.executeQuery("SELECT * FROM code");
                   while(rs.next())
                        System.out.println(rs.getString(1));
              catch(SQLException ex1)
                   System.out.println(ex1.getMessage());
    }it shows this as exception :"com.mysql.jdbc.Driver"
    why is that? I set the class path as : e:\mysql-connector-java-5.0.3\mysql-connector-java-5.0.3-bin.jar
    Thanks
    Kris

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

  • Where can I find a step by step tutorial for for creating a desktop app that connects JSwing components to a Java DB or Mysql Database?

    I am using Netbeans 7.4.
    I would like one that would show me how to connect to the database and how to use code snippets on an ActionPerformed event that would Create, Delete, and Save new records as well as navigate the database, Using as many images as possible.
    That's probably a pretty tall order!
    Thanks,
    Paul

    Hi Paul,
    The below is the best and most trusted source
    Lesson: Learning Swing with the NetBeans IDE (The Java&amp;trade; Tutorials &amp;gt; Creating a GUI With JFC/Swing)

  • Java studio Creator  Mysql

    How can I use mySql and JSC does anybody know where I can find examples thankz

    I just had to do it again and that refreshed my memory :) Do this:
    - start Tomcat
    - run Tomcat admin tool (http://localhost:8080/admin). Tomcat admin does not come with newer versions of Tomcat. You can get it here: http://tomcat.apache.org/download-55.cgi
    - In the left pane, expand Service(Catalina), expand Host(localhost), Expand Context (YourProjectName)
    - click 'Data Sources' and click the name of your data source in the right frame
    - fill in the form, just like you did in JSC
    - click 'save' and click 'commit changes'
    - start Tomcat manager tool (http://localhost:8080/manager/html)
    - reload your app by clicking 'Reload' link
    That should be the most simple way to do it. You can play with server.xml, if you wish :D

  • Java Persistence API + mySQL and East Europe characters

    Hi,
    I use Sun Application Server 9.0 and mySQL 4.1.20 on Linux. When I put data (with jsf form) into my database table everything is displayed correctly until I restart application server (or redeploy my web app). After restarting server non-ascii characters look strange. I suppose that there is a problem with character coding (between apps server and database) but I can't find any solution. I use UTF-8 character coding both in database fields and for displaying jsf pages.
    There are't any problems when I use Derby database for starage data.
    Thanks

    Can you give some more information ?
    Are you using netbeans 5.5 or doing this program standalone and interfacing
    directly with appserver ?
    Can you send a pointer to a gif of the incorrect looking characters ?
    Can you elaborate about putting data using jsf form and some details
    or extract from the code that writes or reads the data ?
    Do the names of your table or columns have the european characters
    in them or is it just the data ?
    Thanks for your help.
    >
    Thanks
    Hi,
    I use Sun Application Server 9.0 and mySQL 4.1.20 on
    Linux. When I put data (with jsf form) into my
    database table everything is displayed correctly
    until I restart application server (or redeploy my
    web app). After restarting server non-ascii
    characters look strange. I suppose that there is a
    problem with character coding (between apps server
    and database) but I can't find any solution. I use
    UTF-8 character coding both in database fields and
    for displaying jsf pages.
    There are't any problems when I use Derby database
    for starage data.
    Thanks

  • Java mysql OK with Terminal but not OK with Apache local web server

    With terminal I have :
    CLASSPATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/:/Library/Java/Extensions/:./
    SUDO_GID=20
    SECURITYSESSIONID=210800
    _=/usr/bin/printenv
    127:/Library/WebServer/Documents/Java root# java TestMySQL
    2006-05-21 13:39:00.0 ************************************************** = OK
    127:/Library/WebServer/Documents/Java root#
    import java.sql.*;
    * mysql-connector-java-3.1.12-bin.jar
    *   % javac /Library/WebServer/Documents/Java/TestMySQL.java
    *   % java TestMySQL
    public class TestMySQL {
            public static void main(String argv[]) throws Exception {
                    // Load the driver class
                    Class.forName("org.gjt.mm.mysql.Driver");
    1                //Class theClass = null;
    2               //try {
    3                //    theClass = Thread.currentThread().getContextClassLoader().loadClass("org.gjt.mm.mysql.Driver");
    4                //}
    5                //catch (ClassNotFoundException e) {
    6                //    theClass = getClass().getClassLoader().loadClass("org.gjt.mm.mysql.Driver");
    7                //}
                    Connection conn = DriverManager.getConnection(
                            "jdbc:mysql:///test",
                    Statement stmt = conn.createStatement();
                    ResultSet rset = stmt.executeQuery("SELECT now();");
                    while (rset.next()) {
                            System.out.println(rset.getString(1));
                    // Close result set, statement and DB connection
                    rset.close();
                    stmt.close();
                    conn.close();
    }I have a simple TestMySQL.html file with applet TestMySQL.class in it.
    Nothing but "Applet TestMySQL not inited"
    When I uncomment the try/catch lines (lines 1 to 7) , java compiler generate an error... near getClass().getClassLoader().loadClass("org.gjt.mm.mysql.Driver");
    With "Class.forName("org.gjt.mm.mysql.Driver");" no problem.
    Running MacOS X 10.3.9, Apache/1.3.33 (Darwin) PHP/4.4.1 mod_ssl/2.8.24 OpenSSL/0.9.7i and JVM 1.4.2_09
    Thanks for help.
    P.S. This my first approach to java/mysql but I would like to see this short program running on my local web server ...
    Thanks.

    hi :-)
    can you post the stack trace?
    im not sure what is causing the error because of less info,
    but have you tried to copy the driver of mysql to tomcat lib folder?
    regards,

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

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

    Moderator action: crosspost deleted.

  • Connectivity java with mySql

    Hi
    Can any one tell me how should i connect my java application with mySql database here is the small code which i written.
    import java.sql.*;
    class tryjdbc
         public static void main(String[] args) throws Exception
         try
              Class.forName("com.mysql.jdbc.Driver").newInstance();
              String connectionURL = "jdbc:mysql://localhost:3306/learn?user=root;password=";
              Connection connection = DriverManager.getConnection(connectionURL, "root", "");
              Statement statement = connection.createStatement();
              ResultSet rs = statement.executeQuery("Select ecode from emp");
              while (rs.next())
                   System.out.println(rs.getString("ecode"));
              catch (Exception e){
                   System.out.println(e);
    Can any one please tell me the error there is no eror in compiling but at run time it gives error
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    Thanks in advance
    Dhiraj

    Hi Dhiraj,
    String connectionURL = "jdbc:mysql://localhost:3306/learn?user=root;password=";
    Connection connection = DriverManager.getConnection(connectionURL, "root", "");
    It seems to be your trying to pass twice of your properties details. One from through URL and another from by pasing the parameters on getConnection() method. Better to avoid to use two place in same application. and one more thing I want to confirm r u using "stable" Driver or "alpha" Driver.
    Raju

  • Java mysql connectivity

    hi
    i m trying to connect to mysql database through java. i have mysql-java-connector jars file placed in the JAVA_HOME\jre\lib\ext directory.
    now when i try to run this file its starts givin me this error...............
    Exception in thread "main" java.lang.NoClassDefFoundError: Test
    the java file that im running is this............(Test.java)
    import java.sql.*;
    import java.util.*;
    import java.net.*;
    import java.io.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.*;
    class Test
         public static void main(String args[])
              System.out.println("Hello");
              System.out.println("Welcome to the world of java");
              System.out.println("Lets learn java.");
              String url="jdbc:mysql://localhost:3306/database";
              Connection con = null;
              Statement stmt = null;
              ResultSet rs = null;
              String query;
              try {
              try{
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
              catch(Exception e)
                   System.out.println("driver not found"+e.getMessage());
                   con = DriverManager.getConnection (url, "", "");
                   stmt = con.createStatement();
                   query = "select * from test;";
                   ResultSet result = stmt.executeQuery(query);
                   while(result.next())
                   String callNumResult = result.getString("name");
                   System.out.println(callNumResult);
              catch(Exception e)
                   System.out.println("SQLException caught: " + e.getMessage());
              finally {
                   try {
                        if (con != null) con.close();
                   catch (SQLException e) {}
    i have also tried adding that mysql-java connector jar file to the classpath........
    but all in vain.....the error persists.
    plz help me with it.........
    ankur

    hi
    i m trying to connect to mysql database through java.
    i have mysql-java-connector jars file placed in the
    JAVA_HOME\jre\lib\ext directory.That's a terrible place to put them. Only language extensions (e.g., packages that start with javax) belong in there. Put that JAR closer to your application.
    >
    now when i try to run this file its starts givin me
    this error...............
    Exception in thread "main"
    java.lang.NoClassDefFoundError: TestLook at the exception: it's complaining about Test, NOT the MySQL JDBC driver class.
    You obviously don't understand how CLASSPATH works:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
    I think you have to add the current directory to the CLASSPATH in order to run your Test:
    java -classpath . TestNote the "dot" after -classpath. That tells the class loader to start looking in the current directory. since your Test.java doesn't have a package statement, I'm assuming that Test.class is in the same directory as Test.java.
    >
    >
    >
    the java file that im running is
    this............(Test.java)
    import java.sql.*;
    import java.util.*;
    import java.net.*;
    import java.io.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.*;
    class Test
    public static void main(String args[])
    System.out.println("Hello");
    System.out.println("Welcome to the world of java");
    System.out.println("Lets learn java.");
    String url="jdbc:mysql://localhost:3306/database";
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    String query;
    try {
    try{
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    catch(Exception e)
    System.out.println("driver not found"+e.getMessage());
    con = DriverManager.getConnection (url, "", "");
    stmt = con.createStatement();
    query = "select * from test;";
    ResultSet result = stmt.executeQuery(query);
    while(result.next())
    String callNumResult = result.getString("name");
    System.out.println(callNumResult);
    catch(Exception e)
    System.out.println("SQLException caught: " +
    e.getMessage());
    finally {
    try {
    if (con != null) con.close();
    catch (SQLException e) {}
    i have also tried adding that mysql-java connector jar
    file to the classpath........
    but all in vain.....the error persists.
    plz help me with it.........
    ankur

Maybe you are looking for

  • Inserting chart in a run report

    In my run_report screen, when I go to chart, I find it is disabled or dim. How should I be able to inssert chart of my choice based on the instant data on the run_report. Any one, please help me.

  • Pro COBOL / Precompile and run with Micro Focus Server Express in Unix AIX

    I have Oracle 11g R2 DB and client installed in Unix AIX machine. I would like to make a simple test pgm to : 1. the precompile using procob on the sample program 2. compile it through Micro Focus Server Express 3. run the sample This sample pgm will

  • RME Hardware Inventory Report gets Error: Report Could Not be Found

    LMS 3.2 RME 4.3.0 When running Inventory Hardware report I select all devices and it shows the correct number of devices selected However, the report is missing all routers, and I get the error message Report could not be found.

  • Retrieval of dates from Personnel Work Schedule Records.

    Hi friends, I need to develop a user exit in which retrieves dates for a current calendar year. For Eg: For Calendar year 2008 There are 2 workschedules . 1) From 06/01/08 to 12/31/08 (Current record) 2) From 01/01/08 to 05/31/08 (Immediate previous

  • Macbook Pro and Backlight control

    I have a macbook pro 6,2 and I'm having problems getting the backlight control working.  I've installed pommed but it seems to be having trouble with this system. When I run pommed -d, I get this (amongst other, I think, irrelevant info)... DMI vendo