Guest User

Untitled

a guest
Feb 27th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.ResultSet;
  4. import java.sql.Statement;
  5.  
  6. import com.microsoft.sqlserver.jdbc.SQLServerDriver;
  7.  
  8. public class SqlConnections {
  9. public static void main(String[] args) {
  10.  
  11. try
  12. {
  13. //Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  14. DriverManager.registerDriver( new SQLServerDriver() );
  15.  
  16. String userName = "xxx";
  17. String password = "xxx";
  18. String url = "jdbc:sqlserver://server=10.xxx.xx.xx\SQLEXPRESS;database=BTP_NYA";
  19. Connection con = DriverManager.getConnection(url, userName, password);
  20. Statement s1 = con.createStatement();
  21. ResultSet rs = s1.executeQuery("SELECT TOP 1 * FROM [BTP_TEST].[xx].[ers]");
  22. String[] result = new String[20];
  23.  
  24.  
  25. } catch (Exception e)
  26. {
  27. e.printStackTrace();
  28. }
  29.  
  30. }
  31. }
Add Comment
Please, Sign In to add comment