File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cant connect to mysql

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have mysql installed on my machine and also i have set it up in my ide which is netbeans i have trying to perform simple databse operation
like follows
now my problem is

thanks for reading this

and one more thing my (mysql ) is runnng fine there is no problem in mysql
 
Campbell Ritchie
Sheriff
Pie
Posts: 47281
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume that "MySQL is running" means you can run it from the command line.
How are you adding those drivers to the classpath? Always set the classpath locally, not as a system variable.
How are you passing the password?
Is jdbcodbc the right sort of Driver? Have you been through the MySQL handbook, which has a chapter in about connecting from Java™? Try § 20.3.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I presume that "MySQL is running" means you can run it from the command line.
How are you adding those drivers to the classpath? Always set the classpath locally, not as a system variable.
How are you passing the password?
Is jdbcodbc the right sort of Driver? Have you been through the MySQL handbook, which has a chapter in about connecting from Java™? Try § 20.3.

no campbell this is not the code for the mysql this code is for connecting to the microsoft sql server with jdbcodbc driver
i m asking what should be the path means driver path in this code for connecting to mysql server
 
Campbell Ritchie
Sheriff
Pie
Posts: 47281
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aren't the details in the MySQL documentation I mentioned earlier? You have to download a .jar with the connector in, and add it to your classpath. Don't set the classpath permanently.

And you are confusing me, asking about MySQL and showing SQL Server driver names.
 
Vishal Trivedi
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use to have following line for my examples
Driver Instance
Class.forName("com.mysql.jdbc.Driver").newInstance();

getting connection
("jdbc:mysql://localhost/ databaseName", "UserName", "Password")


these features are however vendor specific. I had MySQLConnector
Downloaded it from the MySQL website

And besides there is plenty on the web about it.

 
Campbell Ritchie
Sheriff
Pie
Posts: 47281
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Trivedi, thank you. That looks correct. Only, don't display a password, otherwise malicious code or naughty people may be able to read it and use it to harm you.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic