Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. public class ConnectionClass {
  2. String ip = "192.168.1.212:2005";
  3. String classs = "net.sourceforge.jtds.jdbc.Driver";
  4. String db = "rbelz";
  5. String un = "neka";
  6. String password = "neka123";
  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 + ";encrypt=fasle" + ";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. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement