locked
Sql server r2 Jdbc 4.0 java problem RRS feed

  • Question

  • I am new in sql server2008

    when i run my jdbc program the program does not show any output or exception.

    I used these code in eclipse.

    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

    Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=testdb;user=sa;password=123");

                            

    i

    if(con!=null){
    System.out.println("Connected");
    }

    Statement sm = con.createStatement();

    String sql1="select * from dbo.Table1";
    ResultSet rs = sm.executeQuery(sql1);
                while (rs.next()){
    System.out.println(rs.getInt(1));

    }

    I debug the code but the control is terminated on Resutset rs=sm.executeQuery() please kindly help me.

    Sunday, July 13, 2014 7:34 AM