Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Connecting to a database without the JDBC - ODBC bridge (SQL Server and MySQL)?

 
Jim McKinley
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have yet to try to connect to a database without the JDBC - ODBC bridge.

Can someone provide a simple example connecting to Microsoft SQL Server using JDBC? Also, how do you do a query? Possibly just to loop through a simple set of data and then; finally, closing the database. IF I could see a simple/complete example, I think it would help immensely or at least provide enough information that I can ask more meaningful questions.

If possible, can someone show doing a similar example in MySQL?

I've been trying to find some examples but either the examples leave out important steps OR the examples I've found use the JDBC - ODBC bridge.

Thanks in advance!!
 
Roel De Nijs
Sheriff
Posts: 10763
148
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jim McKinley,

First of all, a warm welcome to CodeRanch!

Jim McKinley wrote:Can someone provide a simple example connecting to Microsoft SQL Server using JDBC? Also, how do you do a query? Possibly just to loop through a simple set of data and then; finally, closing the database. IF I could see a simple/complete example, I think it would help immensely or at least provide enough information that I can ask more meaningful questions.

I would be really surprised if searching for "java jdbc example" (or something similar) would not give you tons of code examples to connect to a database using JDBC.

Jim McKinley wrote:If possible, can someone show doing a similar example in MySQL?

That's the beauty of using JDBC: just put another driver on your classpath, use a different JDBC url and the code example for Microsoft SQL Server will work for MySQL as well.

Hope it helps!
Kind regards,
Roel
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!