Connecting to MS SQL problems  
Author Message
Luke Webber





PostPosted: 2004-5-20 7:08:00 Top

java-programmer, Connecting to MS SQL problems "yelp666" <email***@***.com> wrote in message
news:email***@***.com...
>
> Hi all,
> I am trying to connect to MS SQL Server installed on my computer, I
> follow the tutorial, that can be downloaded from sun's web page, but it
> doesn't work. Whatever I try, I get the seme error:
>
> ODBC Driver Menager: Unable to locate the name of data origin, and
> there are no default drivers.
>
> My code:
>
>
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> String url = "jdbc:odbc:Northwind";
> java.sql.Connection con = java.sql.DriverManager.getConnection(url,
> "test", "krowa");
>
> I appreciate any help.

I would recommend that you use the JTDS JDBC driver instead of JDBC.

http://jtds.sourceforge.net/

Luke


 
kaeli





PostPosted: 2004-5-20 20:20:00 Top

java-programmer >> Connecting to MS SQL problems In article <email***@***.com>, yelp666.16iso1
@mail.codecomments.com enlightened us with...
>
> My code:
>
>
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> String url = "jdbc:odbc:Northwind";
> java.sql.Connection con = java.sql.DriverManager.getConnection(url,
> "test", "krowa");
>
> I appreciate any help.
>

You forgot to register the driver with DriverManager.


--
 
Eric





PostPosted: 2004-6-12 6:43:00 Top

java-programmer >> Connecting to MS SQL problems This is from the sun tutorial:
"You do not need to create an instance of a driver and register it with the
DriverManager because calling Class.forName will do that for you
automatically. If you were to create your own instance, you would be
creating an unnecessary duplicate, but it would do no harm.

When you have loaded a driver, it is available for making a connection with
a DBMS. "



What you likely have not done is go to the ODBC data source manager in the
Control Panel and create a new ODBC data source connected to the SQL Server.
If you create a data source name SqlSvr1 and set the default db to
Northwind, then use the con url "jdbc:odbc:SqlSvr1" to get the connection.



"kaeli" <email***@***.com> wrote in message
news:email***@***.com...

> In article <email***@***.com>, yelp666.16iso1
> @mail.codecomments.com enlightened us with...
> >
> > My code:
> >
> >
> > Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> > String url = "jdbc:odbc:Northwind";
> > java.sql.Connection con = java.sql.DriverManager.getConnection(url,
> > "test", "krowa");
> >
> > I appreciate any help.
> >
>
> You forgot to register the driver with DriverManager.
>
>
> --
> --
> ~kaeli~
> She was engaged to a boyfriend with a wooden leg but broke
> it off.
> http://www.ipwebdesign.net/wildAtHeart
> http://www.ipwebdesign.net/kaelisSpace
>