Results 1 to 8 of 8
  1. #1
    sudukrish is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    Default JDBC commands for connecting to sqlserver

    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver").newInstance();
    con = DriverManager.getConnection("jdbc:microsoft:sqlser ver://192.178.6.89:1433/newton","user","passwordr");


    this is the command i am executing but i am getting

    java.sql.SQLException: No suitable driver error



    kindly lemme know what is wrong with this ??

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    See similar recent posts. You have to download and install the driver that you want to use.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  3. #3
    sudukrish is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    Default

    I have the driver installed...there is no problem in instantiating the driver but the problem is in query string

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    java.sql.SQLException: No suitable driver error means there is a problem with the driver setup. Read the documentation that came with the driver to see how to use it.

    If you think it is a problem with your query strings then take it to an SQL forum rather than a Java forum.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  5. #5
    sudukrish is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    Default

    Thank you for your response.But when I meant query string i meant the second statement i.e con = DriverManager.getConnection("jdbc:microsoft:sqlser ver://192.178.6.89:1433/newton","user","passwordr");

    I am not sure if this formation is right ?

  6. #6
    sudukrish is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    Default

    If the driver is not installed properly I would think it wud throw an exception in the first statement itself.My first statement is getting though properly but the second one throws an exception

  7. #7
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    As I said, the documentation for the driver will tell you the url format you should use. Your SQL server provider will tell you what address and port you should use and you should know your database name, username and password.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  8. #8
    jasmu is offline Member
    Join Date
    Apr 2009
    Posts
    17
    Rep Power
    0

    Default

    I too had same problem, if i do like that.

    con = DriverManager.getConnection("jdbc:microsoft:sqlser ver://192.178.6.89:1433/newton","user","passwordr");

    Then i deleted the database name, like this,

    con = DriverManager.getConnection("jdbc:microsoft:sqlser ver://192.178.6.89:1433","user","passwordr");

    then i worked...

    I think there will be setting in sql server, to open our database directly..

    Try this.

    If u found any other solution.. intimate me also...

Similar Threads

  1. Replies: 1
    Last Post: 02-23-2009, 07:48 PM
  2. Replies: 1
    Last Post: 10-16-2008, 03:09 PM
  3. JSP Connecting to MS SQL SERVER 2000 using JDBC
    By hisouka in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 09-02-2008, 10:23 AM
  4. Tomcat with SQLSERVER 2005
    By bbq in forum JDBC
    Replies: 1
    Last Post: 07-05-2007, 05:40 AM
  5. SQLServer 2000 EXCEPTION
    By Heather in forum JDBC
    Replies: 3
    Last Post: 06-29-2007, 04:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •