Advertisement
Guest User

Untitled

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