• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cant connect to mysql

 
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic