Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC would'nt connect to mysql

 
Vasanthan Dharmar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been trying to connect to MYSQl database. Just learning JDBC and this is my first sample program.I use netbeans IDE. I also tried executing it from the command prompt and still i get hte same error.



Compiles fine but throws up this error

Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)

I searched the web and came across few solutions

1) Checked the class pathlike 100 times.
2)Used mysql-connector-java-bin-3.1.8 instead of mysql-connector-java-bin-3.1.8-g
3)unzipped the aspectjrt.jar file and set included that directory to the class path.

Still doesnt seem to work!
Got suggestions to help me out?

[ July 01, 2005: Message edited by: Bear Bibeault ]

[Jeanne added code tags]
[ July 02, 2005: Message edited by: Jeanne Boyarsky ]
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vasanthan,

It definately looks like a classpath issue.
But, if you are just learning JDBC, I suggest you not mix it up with any Aspect J stuff. That will narrow down the code that you need to check to find the cause of error.
 
Vasanthan Dharmar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, I do take it as my fault. I use netbeans ide.

I have set up the class path My libray. When i expand the my library icon. I do see the org.aspectj.lang.signature class file. This library is also included the project.

So basically stumped.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34378
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vasanthan,
Welcome to JavaRanch!

Since this looks like a question about using Netbeans with AspectJ, I'm moving this to our IDEs forum.
 
Matan Mazursky
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haha, netbeans JDBC
I struggled with this for a while myself.
here's my code:
import java.sql.*;
public void connect() throws Exception
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=m1a2t3a4n5");
}

This works after having added to libraries the appropriate JAR, who's name is: mysql-connector-java-3.1.10-bin.jar

Tell me if you need that JAR.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic