Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to begin ?

 
Steven Zeng
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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:
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • 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
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic