• 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

JDBC Connectivity

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,I am Running "CreateCoffees.java" example given on sun.java site.
My program has complied correctly. I have used "url" as suggested by Tutorial. While running Java file I m Getting Following Error.

SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified

I have used used dirver path as followed.....
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

I request you to help me in order to over come this Problem.
Thanks...
 
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you need download the specific database driver , and add the driver jar file into your classpath.

Each database has its own jdbc database driver. for example, oracle use class14.zip; MySQL use mysql-connector-***-bin.jar. You can find this info in the database vendor website.
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Siddhesh Desai,

What's the URL suggested by the tutorial? I can't be bothered to go hunting for it. Is it "jdbc:mySubprotocol:myDataSource"? If so then you need to change it to "jdbc:odbc:Coffees" or something like that. Then you need to run odbcad32.exe in Windows and set up a System DSN named Coffees. You need to set this up for the database that you've chosen to create your tables on. Follow the step-by-step instructions in the ODBC connection wizard, which are typically different for each type of database.

Alternatively you can follow Edward Chen's advice and forget about the JDBC/ODBC bridge driver and locate or download a JDBC driver specifically for your database of choice. These drivers typically come with instructions on how to use them from within Java.

Hope that helps.

Jules
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if u are using ms sql server 2000 or ms access then pls configure the dsn
this can be done by going to controlpanel->administrative tools->data sources

open and select the dsn u want to create
usually it works with user dsn

in the program add the line

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

connection con = driver.getConnection("jdbc dbc sn_name","username","pass");

thanks
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
connection con = DriverManager.getConnection("jdbc dbc sn_name", "un" "pass");
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic