Make sure you are using a System DSN, not a User DSN when you set up your
ODBC DSN.
----- Original Message -----
Sent: Tuesday, July 27, 1999 8:32
PM
Subject: Cann't set up Connection in
init()
Hi, everyone, please help me out,
I encountered a strange problem.
When I want to use jdbc-odbc-brider to set up a
database Connection in function init() of a servlet, I get the following
error:
java.sql.SQLException:
[Microsoft][ODBC SQL Server Driver]Client unable to establish
connection
Here is the snip of code:
public void init() throws
ServletException
{
super.init();
String szURL =
"jdbc:odbc:"+"MyDSN";
try {
Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver");
m_con = DriverManager.getConnection
(szURL, "sa", "");
} catch (SQLException e)
{
System.out.println(e.toString());
}
catch (java.lang.Exception e) {
// Got some other type of
exception. Dump it.
e.printStackTrace
();
}
}
Thanks in advance.
Jianhong