Advertisement
Guest User

Untitled

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