This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic