Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

newbie: Problem with jdbc-odbc and MS SQL server 2005

843859Oct 30 2007 — edited Oct 31 2007
I'm on win vistax64 with SQLSERVER 2005 and I have set up the odbc source as system dsn using the SQL Native Client driver with SQL authentication and the connectivity test in the end succeeds.

I'm trying to make a simple web app that will connect to the database and perform simple querries. It's a school assignment.

I'm using the jdbc-odbc bridge because it's the simplest way to do it and it's what we were shown in class.

I get the following irritating error:
"Cannot establish a connection to jdbc:odb:sstmdb using sun.jdbc.odbc.JdbcOdbcDriver ([Microsoft][ODBC Driver Manager] Data source name not found and no default driver specifies)".
I'm working with netbeans 5.5.1 and this error is what I get when in the runtime tab I try to connect with the jdbc-odbc. I get a similar error in the logs when I try to run the app on the j2ee server.



This is the java class that establishes the connection.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Connector {
    private static final String dbUrl="jdbc:odbc:sstmdb";
    private static final String user="kimon";
    private static final String password="jackohara";

    public static Connection getConnection(){
        Connection conn = null;
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            conn = DriverManager.getConnection(dbUrl,user,password);
        } catch (SQLException e) {
            e.printStackTrace();  
        } catch (ClassNotFoundException e) {
            e.printStackTrace();  
        }
        return conn;
    }
}
It has worked perfectly on my school PC with winXP and MSDE2000.




What am I missing?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 28 2007
Added on Oct 30 2007
1 comment
143 views