Results 1 to 2 of 2
  1. #1
    Crisanto is offline Member
    Join Date
    Oct 2008
    Posts
    4
    Rep Power
    0

    Default Problem connect to SQL Server

    Hi

    I have a problem connecting my Java program to SQL Server.
    In this statement "Class.forName(driver);" it jumps to catch the exception.
    and get this error - at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at Newtest.getConnection(Newtest.java:20)
    at Newtest.main(Newtest.java:33)
    Is there something missing in my Eclipse setup? I am very new to eclipse and java.

    Can someone help me please!!!!

    Here is my code:
    import java.sql.Connection;
    import java.sql.DriverManager;

    public class Newtest {

    public Newtest(){

    }
    public static String strErrorDtls = "";

    /** Get database connection */
    public Connection getConnection() {
    Connection conn = null;
    try {

    String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver" ;

    String uri = "jdbc:microsoft:sqlserver://192.168.1.251:1433/3G_Test";

    Class.forName(driver);

    conn = DriverManager.getConnection(uri, "sa", "apptest");
    System.out.println("connection is up");
    } catch (Exception ex) {
    ex.printStackTrace();
    strErrorDtls += ex.getMessage() + " ";
    }
    return conn;
    }

    public static void main(String args[]){
    Newtest dbms = new Newtest();
    dbms.getConnection();


    }
    }

  2. #2
    mmilinkov is offline Member
    Join Date
    Dec 2008
    Posts
    1
    Rep Power
    0

    Default

    Crisanto,

    I think that the best way to get this question answered would be to post to the "Eclipse Newcomers" newsgroup.

    BTW, you will need to register to post on the newsgroup. We do this to password protect the groups to make them less vulnerable to spambots.

    Apologies for not directly giving you links to the above. Apparently you have to earn the right to be helpful on these forums :-(

Similar Threads

  1. how to connect a server to multiple clients?
    By azhar in forum Networking
    Replies: 15
    Last Post: 03-22-2010, 12:54 PM
  2. Replies: 0
    Last Post: 08-25-2008, 02:13 PM
  3. Server not able to connect client
    By Kapil Gupta in forum New To Java
    Replies: 15
    Last Post: 07-22-2008, 04:09 AM
  4. connect to web server from mobile using java app.
    By jankrishnan in forum Advanced Java
    Replies: 1
    Last Post: 07-15-2008, 04:12 PM
  5. Replies: 4
    Last Post: 06-05-2007, 01:45 AM

Posting Permissions

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