Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / July 2004

Tip: Looking for answers? Try searching our database.

can't connect to msssql

Thread view: 
Georg Andersson - 22 Jul 2004 10:55 GMT
hi the code below is supposed to establish a connection to my database
located on a sql-server. but there is always thr following exception:
java.sql.SQLException: No suitable driver

i have downloaded the driver from microsoft
(http://www.microsoft.com/downloads/details.aspx?FamilyID=86212d54-8488-481d-b46b
-af29bb18e1e5&DisplayLang=en
)
and copied the 3 jar-files to C:\Program Files\
j2sdk1.4.2_04\jre\lib\ext and C:\Program Files\Java\
j2re1.4.2_04\lib\ext.

any ideas what i'm doing wrong?

public void testCON(){
 Connection connection = null;
 try {
   String driverName =
("com.microsoft.jdbc.sqlserver.SQLServerDriver");
   Class.forName(driverName);
   
   String serverName = "lt51s";
   String mydatabase = "ADMS";
   String url = "jdbc:mysql://" + serverName +  "/" + mydatabase;
   String username = "user";
   String password = "password";
   connection = DriverManager.getConnection(url, username, password);
 }catch (ClassNotFoundException e) {
   System.out.println(e);
 }catch (SQLException e) {
   System.out.println(e);
 }
}
Manfred Rosenboom - 22 Jul 2004 12:23 GMT
>     String url = "jdbc:mysql://" + serverName +  "/" + mydatabase;

Your JDBC URL is wrong!

Try the following one:

String url = "jdbc:microsoft:sqlserver://" + serverName + ";databaseName=mydatabase"

Best,
Manfred


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.