Hello, this is the code that i use to connect to SQL Server 7.0 Try it:

public void connect(String strDsnName) throws UnavailableException {
try {

// Load the jdbc-odbc bridge
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

// the jdbc database name
String strDbName = "jdbc:odbc:" + strDsnName;
m_con = (Connection)DriverManager.getConnection(strDbName, "sa", "");
} catch(ClassNotFoundException cnFex) {
// Catch the class not found exception
        throw new UnavailableException(this, "Couldn't find class");
} catch (SQLException sqle) { // Catch the SQLException
        throw new UnavailableException(this, "Couldn't connect to DB" );
}

}

Your code uses "jdbc.odbc...." where mine uses "sun.jdbc.odbc..."

Hope it helps,
Pankaj

========================================
Michael Chung <[EMAIL PROTECTED]> wrote:
Hi everybody,

I tried to run a servlet example called 'coffee.java'.  (See attached
code sample)
My problem is I don't know how to put the correct odbc driver for this
line of code:
...
try {
    Class.forName("jdbc.odbc.JdbcOdbcDriver");  // ( I've got error on
this.)
                             ^^^^^^^^^^^^^^^^^^^^^
 }
...
By the way, I'm using MS SQL Server 7.0 trial edition on windows NT 4.0.

My data source name = 'sql_svr'
My Database name='mydb'
My table name='myInfo'
My login ID='Administrative'
My password='admin'

Does anybody have succeeded to connect to a Microsoft SQL Server
database using servlet?
If so could you give me an example?
Really much appreciated.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html


____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to