• 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

How to begin ?

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,all.I am eager to know how to connect to database,for example Oracle or MS Sql server, through JDBC.I have learn that I should make use of java.sql package.But when I finished the reading of the API ,I had not found how to begin yet. Anybody would be kind enough to give me a instuction in detail to build this connection in steps?Especially,I want know the following questions :First, how can i know the names of the database drivers.If I have a database of Oracle8.15,so what is the name of its driver I mean the name like "com.inet.tds.TdsDriver"?Second,if I use "Connection connection = DriverManager.getConnection(url,login,password)",does this mean I have established the connection? :roll:
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Steven
Have you seen the JDBC tutorial at Sun's site. It is pretty good and gives decent examples of how to get started.
Not all databases have a specific Java driver, although, I would think that most, if not all, Oracle products will. Places to look would be the companies web site or even a general search on the web should find one for you. If it is a DB that can use ODBC you can use the JDBC-ODBC bridge driver that should come with your install.
If the getConnection method returned fine and didn't throw any exceptions then, yes, you did connect to the database.
hope that helps
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dave Vick:
Steven
Have you seen the JDBC tutorial at Sun's site. It is pretty good and gives decent examples of how to get started.
Not all databases have a specific Java driver, although, I would think that most, if not all, Oracle products will. Places to look would be the companies web site or even a general search on the web should find one for you. If it is a DB that can use ODBC you can use the JDBC-ODBC bridge driver that should come with your install.
If the getConnection method returned fine and didn't throw any exceptions then, yes, you did connect to the database.
hope that helps


For Oracle specific stuff, I have previously posted a
list of resources to get started. It includes steps from downloading the jdbc drivers for Oracle to setup, to sample code for connecting and retrieving data, to error messages and FAQ.
Jamie
 
Steven Zeng
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,Dave and Jamie,thanks a lot.The resource you supplied are pretty good.I have found where to begin.
 
reply
    Bookmark Topic Watch Topic
  • New Topic