facebook

[Closed]MS SQL Java app console testing

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #264440 Reply

    Mark Sanders
    Member

    Windows XP sp2
    msSQL 2005 (local)

    i’m just doing some testing. i have been able to set up my DBExplorer conction to my SQL server access tables and run some querys.

    what i have done now is created a Java application and i am trying to test some code to produce results in the console. the test works fine if i use the following piece (partial) of code:

    Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);//load JDBC DRIVER
    Connection con = DriverManager.getConnection(“jdbc:odbc:PhaseGates;integratedSecurity=true”);
    //get connection

    when i use the following instead:
    Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);//load JDBC DRIVER
    Connection con = DriverManager.getConnection(“jdbc:sqlserver://localhost:1433;databaseName=PhaseGates;integratedSecurity=true”);
    //get connection
    I get the following error:

    java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.DBconn.Test1.main(Test1.java:15)

    I have a feeling i need to placing the sqljdbc.jar file somewhere for eclipse or myeclipse to see it.

    any ideas?

    thanks,

    #264447 Reply

    Haris Peco
    Member

    littleccguy,

    Yes, you have to download MS jdbc driver from http://msdn.microsoft.com/data/ref/jdbc (there is jTDS driver as well) and set in your project classpath

    Regards,

    #264516 Reply

    Mark Sanders
    Member

    Thank you.

    I will do that.

    #264517 Reply

    Mark Sanders
    Member

    Thank you.

    I will do that.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: [Closed]MS SQL Java app console testing

You must be logged in to post in the forum log in