• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting to SQL Server 2000

 
Amarjyoti Das
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
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.*" %>
<!-- HTML COMMENTS -->
<html>
<body>
<!-- declare the parameters passed from the html page-->
<%
try {
// Step 1: Load the JDBC driver.
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
// 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
%>
</body>
</html>
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
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • 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.
/Rene
 
alzamabar
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.
Regards,
Marco
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic