Guest User

Untitled

a guest
Mar 24th, 2017
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package javaapplication1;
  7.  
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.ResultSet;
  11. import java.sql.Statement;
  12.  
  13. /**
  14. *
  15. * @author lab
  16. */
  17. public class JavaApplication1 {
  18.  
  19. /**
  20. * @param args the command line arguments
  21. */
  22. public static void main(String[] args)throws Exception {
  23. // TODO code application logic here
  24. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  25. System.out.println("Driver Registered ");
  26. String connectionUrl = "jdbc:sqlserver://192.168.202.177:1433;" +
  27. "databaseName=Jdbc;user=sa;password=password@123;";
  28. Connection con = DriverManager.getConnection(connectionUrl);
  29. String query = "select name from abc";
  30. Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  31. st.execute(query);
  32. ResultSet rs = st.executeQuery(query);
  33. int i=1;
  34. while(rs.next())
  35. {
  36. rs.absolute(i);
  37. System.out.println(rs.getString(1));
  38. i++;
  39. }
  40. System.out.println("done");
  41. }
  42.  
  43. }
Add Comment
Please, Sign In to add comment