• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Connecting to SQL Server 2000

Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I downloaded and installed Microsoft's JDBC driver. But I could not find any documentation about how to use it. Could you give me some direction. Here is what I am using
<%@ page isErrorPage="false"%>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<!-- declare the parameters passed from the html page-->
try {
// Step 1: Load the JDBC driver.
// Step 2: Establish the connection to the database.
String url = "jdbc:microsoft:sqlserver://servername:1433;DatabaseName=sde;SelectMethod=cursor";
Connection conn = DriverManager.getConnection(url,"user","password");
if (conn == null) {
out.println ("Connection successfully created");
} else {
out.println ("Connection could not be created");

conn = null;
} catch (Exception e) {
out.println ( "Some Exception occured" );
} //end SQLException
When I run the page in my browser I get "Some Exception Occured.
On another note, I have 3 .jar files when I installed the JDBC driver - mssqlserver.jar, mbase.jar and msutil.jar. I could put the complete pathname of the 1st jar file in my classpath (Windows 2000, System->Advanced tab). But my classpath have already become so long that I could not fit the 2 other .jar files. Any suggestions?
Thank you
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could put the jar-files in '<java_home>/jre/lib/ext'
there should be a pdf-doc (usermanual) inside your download from microsoft.
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which is the JSP/Servlet container that are You using? If is Tomcat, You jave to put the *.jar files under CATALINA_HOME/lib directory. *.jar files should be put also in your classpath environment variable.
If You are using Tomcat, the error specification should be visible also in the command window opened when You start it.
The code You wrote seems to me correct.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic