Results 1 to 12 of 12
  1. #1
    vishalrimt is offline Member
    Join Date
    Aug 2010
    Posts
    15
    Rep Power
    0

    Default problem regarding "JDBC"

    Hi all,

    i was trying my first JDBC program, but it gave an exception shown below the code...
    i have set the classpath correctly.. but still there is same exception..
    please help me..:)





    Java Code:
    import java.sql.*;
    
    class DatabaseDemo
    {
    
    public static void main(String zx[])
    {
    
    	try
    	{
    
    		Class.forName("com.mysql.jdbc.Driver");
    
    		Connection con=DriverManager.getConnection("jdbc:mysql:///test","root","root");
    
    		Statement st=con.createStatement();
    
    		st.executeUpdate("create database t1");
    		st.executeUpdate("use t1");
    		st.executeUpdate("create table emp(name varchar(10))");
    		st.executeUpdate("insert into emp values('Vishal')");
    
    		ResultSet rs=st.executeQuery("select * from emp");
    
    		while(rs.next())
    		{
    			rs.getString("name");
    		}
    
    	}
    	catch(Exception e)
    	{
    		System.out.print(e);
    	}
    
    }
    }



    Java Code:
    C:\java programs\JDBC>javac DatabaseDemo.java
    
    C:\java programs\JDBC>java DatabaseDemo
    Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Sign
    ature
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:169)
            at DatabaseDemo.main(DatabaseDemo.java:12)
    Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.Signature
            at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
            ... 3 more
    
    C:\java programs\JDBC>

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,606
    Rep Power
    23

    Default

    Is this line 12 in your program: Class.forName("com.mysql.jdbc.Driver");
    NoClassDefFoundError: org/aspectj/lang/Signature
    Do you know where the class file in the above message is located? If in a jar, the jar needs to be on the classpath.

  3. #3
    vishalrimt is offline Member
    Join Date
    Aug 2010
    Posts
    15
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Do you know where the class file in the above message is located? If in a jar, the jar needs to be on the classpath.

    hi norm,

    i have written this in classpath:

    C:\Demo\mysql-connector-java-5.0.8-bin-g.jar;.;

    demo is a folder in which the jar file "mysql-connector-java-5.0.8-bin-g" is present..
    is this the right way...?? if so, then still the exception is coming..:(

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    765
    Rep Power
    6

    Default

    explore the jar and check whether above mentioned class is listed or not.
    Ramya:cool:

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,606
    Rep Power
    23

    Default

    Where is the class: org.aspectj.lang.Signature?

  6. #6
    vishalrimt is offline Member
    Join Date
    Aug 2010
    Posts
    15
    Rep Power
    0

    Default

    Quote Originally Posted by RamyaSivakanth View Post
    explore the jar and check whether above mentioned class is listed or not.
    which class are you talking about ramya..??
    There is a class "Driver" in com.mysql.jdbc.Driver and similar file in "org"..

  7. #7
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,018
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Norm View Post
    Where is the class: org.aspectj.lang.Signature?
    It beats me what aspectj has to do with jdbc; as far as I know AspectJ is an aspect oriented extension for Java ...

    kind regards,

    Jos

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,606
    Rep Power
    23

    Default

    Is it a case of executing program A and showing us the code for program B?

    vishalrimt: Do you have any programs that use the org.aspectj.lang package?
    Specifically the Signature class?

  9. #9
    vishalrimt is offline Member
    Join Date
    Aug 2010
    Posts
    15
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Is it a case of executing program A and showing us the code for program B?

    vishalrimt: Do you have any programs that use the org.aspectj.lang package?
    Specifically the Signature class?
    Norm, It is my first ever program by using JDBC... i have no other codes related to it... It is the program which is giving the mentioned exception...:(
    Even i am trying to find the solution for the last complete hour...:(

  10. #10
    vishalrimt is offline Member
    Join Date
    Aug 2010
    Posts
    15
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    It beats me what aspectj has to do with jdbc; as far as I know AspectJ is an aspect oriented extension for Java ...

    kind regards,

    Jos
    Hi Josah,

    Even I am concerned that why the exception is coming on aspectj... Our teacher told us only about the "com.mysql.jdbc.Driver" method...:(

  11. #11
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,606
    Rep Power
    23

    Default

    Usually computers and programs do not involve magic. I'm afraid that is the only explanation I can make for what is happening.

    Can you open the jar file: mysql-connector-java-5.0.8-bin-g.jar
    and see what it contains?

    Do a Google on: mysql-connector-java-5.0.8-bin-g.jar

    See http://forums.mysql.com/read.php?39,22579,207677
    Last edited by Norm; 08-13-2010 at 05:16 PM.

  12. #12
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,018
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by vishalrimt View Post
    Hi Josah,

    Even I am concerned that why the exception is coming on aspectj... Our teacher told us only about the "com.mysql.jdbc.Driver" method...:(
    Maybe you have some AspectJ stuff installed in your jre/lib/ext directory; thoroughly check your installation because as it is now this is going nowhere.

    kind regards,

    Jos

Similar Threads

  1. Replies: 1
    Last Post: 01-21-2010, 09:20 AM
  2. problem with argument list and precedence "(" and ")"
    By helpisontheway in forum Advanced Java
    Replies: 6
    Last Post: 12-24-2009, 07:50 AM
  3. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  4. Replies: 1
    Last Post: 10-20-2008, 07:35 AM
  5. Replies: 1
    Last Post: 03-14-2008, 02:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •