• 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

connecting Java with MS SQL2000 or 7.0

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no experience with this - could you help me with this? i dont know exactly how to get a connection with mssql. I did it before using asp, but now I have to use JSP.
best regards
Rafal Chmielecki
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rafal,
Perhaps, you should start from the JDBC Basics from the Java Tutorial.
Also, you may want to purchase a good book on JSP such as Java Server Pages from Hans Bergsten, available from all major bookstores.

Franck Rasolo
Independent Java Consultant
London, UK

 
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The steps are as follows :
1.Create an ODBC DSN
Using the Windows Control Panel, create an ODBC DSN (data source name) for the database.
2.Load the driver
In a JDBC program, one of the first things to do is to load the JDBC driver by calling the forName() static method of the Class class. forName() takes one string parameter: the name of the driver along with its package. For JavaSoft's JDBC-ODBC Bridge, this string is "sun.jdbc.odbc.JdbcOdbcDriver". Therefore, the call would look like:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
3.Establish a database connection
Once the JDBC driver loads, you can establish a connection to the database using the DriverManager.getConnection() method. This method's first argument is a string that contains the JDBC URL for the database. The second and third parameters are the user name and password, respectively.
A JDBC URL is formulated using the following pattern:
jdbc:<subprotocol>:<subname>
A connection to the database could be established in this manner:
String stUrl_= "jdbc:odbc:myDSN"; // let's say myDSN
// is the name of ODBC DSN
Connection connection_ = DriverManager.getConnection(stUrl_, "sa", "");
Hope that helps.
Parmeet
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic