
JDBC Connection to MS SQL Server 2000
Hi Joe:
I am not sure the correct URL string to set up the
connection to MS SQL Server 2000.
I downloaded the Microsoft SQL Server 2000 driver for
JDBC and installed it.
You mentioned that my URL string in the code is not
right. What is the right URL string for
DriverManager.getConnection(URL)?
Is there any sample code available online? Can you help
me? I would really appreciate your advice.
Feng
Quote:
>-----Original Message-----
>> I am working on a school project which requires
>> database connection to Microsoft SQL server 2000
>> through JDBC-ODBC bridge.
>The exception means that your URL is not exactly what
the jdbc-odbc bridge expects.
Quote:
>Joe
>> Database Server: MS SQL Server 2000
>> OS: Window XP professional
>> Java Version: 1.4.1_02
>> Driver: Microsoft SQL Server 2000 Driver for JDBC
>> Data Source: funfoo (added through ODBC)
>> My Java code:
>> ====================================================
>> import java.sql.*;
>> public class MyODBC
>> {
>> public static void main(String args[])
>> {
>> try
>> {
>> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>> String sourceURL
= "jdbc:Microsoft:sqlserver://funfoo;User=sa;Password=feng
Quote:
>> gui";
>> Connection databaseConnection =
>> DriverManager.getConnection(sourceURL);
>> }
>> catch(ClassNotFoundException e)
>> {
>> System.err.println(e);
>> }
>> catch(SQLException e)
>> {
>> System.err.println(e);
>> }
>> }
>> }
>> ====================================================
>> The above code throws exception as follows:
>> java.sql.SQLException: No suitable driver
>> The Java program is run on the same machine that hosts
>> the MS SQL server 2000. The data source is funfoo
>> which is added through ODBC.
>> I don't know how to solve the above exeption. I am
>> wondering if you would give me a hint on the database
>> connection issue?
>> Feng
>.