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 2007

Tip: Looking for answers? Try searching our database.

SQLExpress

Thread view: 
Clive_ - 16 Jul 2007 10:55 GMT
Hi,

I am trying to build a simple test connection to MS SQLServer (Express
9)

Got an exception:
com.microsoft.sqlserver.SQLServerdriver

It does not like the SQL Server driver??
Could anyone help to solve this problem??

Thanks

Clive

Code, JdbcTest.java:
package project1;

import java.sql.*;
import java.util.*;

class JdbcTest {

   public static void main (String[] args) {
       try {

           // Step 1: Load the JDBC driver.
           String driver="com.microsoft.sqlserver.SQLServerDriver";
           Class.forName(driver);

           Properties props = new Properties();
           props.put("user", "Clive_");
           props.put("password", " ");

           // Step 2: Establish the connection to the database.
           Connection con = DriverManager.getConnection(
                   "jdbc:microsoft:sqlserver://K0322608/SQLEXPRESS:"
                   +"1433;databasename=Calibration", props);

       } catch (Exception e) {
           System.err.println("Got an exception! ");
           System.err.println(e.getMessage());
       }
   }
}
Guido Weber - 16 Jul 2007 19:51 GMT
Hi Clive

try using as driver:
com.microsoft.sqlserver.jdbc.SQLServerDriver

and as connection URL:
jdbc:sqlserver://your_connection_data

these work for me.
HTH
  Guido

Clive_ schrieb:
> Hi,
>
[quoted text clipped - 41 lines]
>     }
> }
Roedy Green - 16 Jul 2007 21:18 GMT
>    // Step 1: Load the JDBC driver.
>            String driver="com.microsoft.sqlserver.SQLServerDriver";
[quoted text clipped - 12 lines]
>            System.err.println("Got an exception! ");
>            System.err.println(e.getMessage());

A few things to check:
1. is "com.microsoft.sqlserver.SQLServerDriver" the nameof the driver,
case sensitive?

2.  is the name of the property "user" rather "userid" etc. case
sensitive.

3. You have a BLANK password. This is not the same as an empty
password.  In examples I put the word "sesame" to indicate a password
without revealing the real one. This is a reference to the Arabian
Nights story, Ali Baba and the Forty Thieves most children read in my
generation.  It is unlikely to be confused with a keyword.

4. Is /K0322608 the nameof the host where the SQL database lives?

5. double check you are supposed to write microsoft:sqlserver: not
microsoft.sqlserver: or similar.

6. add an e.printStackTrace (System.err) to localise just what is
happening.

7. print e so you can find out precisely what sort of exception you
got.

The problem is there is so much specific-to-your case information in
that snippet, only you can check it is correct.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Lew - 16 Jul 2007 21:56 GMT
Clive_ wrote, quoted or indirectly quoted someone who said :
>>    // Step 1: Load the JDBC driver.
>>            String driver="com.microsoft.sqlserver.SQLServerDriver";
[quoted text clipped - 12 lines]
>>            System.err.println("Got an exception! ");
>>            System.err.println(e.getMessage());

> The problem is there is so much specific-to-your case information in
> that snippet, only you can check it is correct.

To the OP: It would also help if you provided the error message you saw,
copied and pasted, not retyped.  Consider providing an SSCCE in future.
<http://www.physci.org/codes/sscce.html>
<http://mindprod.com/jgloss/sscce.html>
(part of <http://mindprod.com/jgloss/newsgroups.html>)

Signature

Lew



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.