somthing wrong about using JDBC-ODBC

Reply

Join Date: Apr 2006
Posts: 2
Reputation: forrest is an unknown quantity at this point 
Solved Threads: 0
forrest forrest is offline Offline
Newbie Poster

somthing wrong about using JDBC-ODBC

 
0
  #1
Apr 27th, 2006
what I use is SQL SERVER 2000,the system is WINXP SP-2
I set the classpath:C:\Borland\JBuilder2005\jdk1.4\lib;.;C:\Program Files\Tomcat 5.0\common\lib;.;
I use the JDBC-ODBC to connect the database,the original code is

package hospital.db;

import java.sql.*;
import hospital.db.*;

public abstract class DBConnection
{
private static Connection conn = null;
public static Connection getConnection()
{
try
{
if(conn == null)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");
System.out.println("Connection created.");
}
else
{
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select count from administrator");
if(rs == null || !rs.next())
{
Class.forName("san.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");
System.out.println("Connection re-created.");
}
}
catch(Exception ex)
{
System.out.println(ex);
}
finally
{
return conn;
}
}
}

there is no problem in connection the database:Connection created. 2006-04-12 11:34:33
but when I put it into the Tomcat 5.0,it always throw something like:
sun.jdbc.odbc.JdbcOdbc.createSQLException() Ln6958[Microsoft][ODBC SQL Server Driver]
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 353
Reputation: aniseed is an unknown quantity at this point 
Solved Threads: 6
aniseed's Avatar
aniseed aniseed is offline Offline
Posting Whiz

Re: somthing wrong about using JDBC-ODBC

 
0
  #2
May 4th, 2006
Could you add a line to print the stack trace?
ex.printStackTrace();
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: somthing wrong about using JDBC-ODBC

 
0
  #3
May 5th, 2006
Try adding the following to the policy file:
  1. grant {
  2. permission java.lang.RuntimePermission
  3. "accessClassInPackage.sun.jdbc.odbc";
  4. permission java.util.PropertyPermission
  5. "file.encoding", "read";
  6. };

the policy file is located under JRE_HOME lib/security

or tomcat may have its own, you will have to search for
a file with poilcy in the name under the tomcat base
directory
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 2
Reputation: ponloges is an unknown quantity at this point 
Solved Threads: 0
ponloges ponloges is offline Offline
Newbie Poster

Re: somthing wrong about using JDBC-ODBC

 
0
  #4
May 5th, 2006
i think there will be problem with the odbc driver you have selected. test the DSN while ur creating. and there may also authendication problem. so check with authendication u have selected with sqlserver.

Its

Pon.logeswaran
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 4215 | Replies: 3
Thread Tools Search this Thread



Tag cloud for JSP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC