Guest User

Untitled

a guest
Aug 11th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. SQL server 2008 R2 connection error / android
  2. System.out.println("MySQL Connect Example.");
  3. Connection conn = null;
  4. String url = "jdbc:jtds:sqlserver://192.168.2.101:1433/INSERTGT";
  5. String dbName = "podmiot";
  6. String driver = "net.sourceforge.jtds.jdbc.Driver";
  7.  
  8.  
  9. String userName = "msi";
  10. String password = "keyboa5";
  11. try {
  12. Class.forName(driver).newInstance();
  13. conn = DriverManager.getConnection(url+dbName,userName,password);
  14. System.out.println("Connected to the database");
  15. int duration = Toast.LENGTH_SHORT;
  16.  
  17.  
  18. Toast.makeText(getApplicationContext(), "Connected to the database", duration);
  19.  
  20. conn.close();
  21. System.out.println("Disconnected from database");
  22. EditText edit1 = (EditText)findViewById(R.id.editText1);
  23. edit1.setText("Disconnected from database");
  24.  
  25. } catch (Exception e) {
  26. e.printStackTrace();
  27. TextView edit1 = (TextView)findViewById(R.id.exception);
  28. edit1.setText("Problem: " + e.toString());
  29. }
Add Comment
Please, Sign In to add comment