Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. public class ConnectionClass {
  2. String ip = "169.254.203.23";
  3. String classs = "net.sourceforge.jtds.jdbc.Driver";
  4. String db = "andro";
  5. String un = "root";
  6. String password = "password";
  7.  
  8. @SuppressLint("NewApi")
  9. public Connection CONN() {
  10. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
  11. .permitAll().build();
  12. StrictMode.setThreadPolicy(policy);
  13. Connection conn = null;
  14. String ConnURL = null;
  15. try {
  16.  
  17. Class.forName(classs);
  18. ConnURL = "jdbc:jtds:sqlserver://" + ip + ";"
  19. + "databaseName=" + db + ";user=" + un + ";password="
  20. + password + ";";
  21. conn = DriverManager.getConnection(ConnURL);
  22. } catch (SQLException se) {
  23. Log.e("ERRO", se.getMessage());
  24. } catch (ClassNotFoundException e) {
  25. Log.e("ERRO", e.getMessage());
  26. } catch (Exception e) {
  27. Log.e("ERRO", e.getMessage());
  28. }
  29. return conn;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement