Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.gilbertojimenezorench.myapp;
- import android.annotation.SuppressLint;
- import android.os.StrictMode;
- import android.util.Log;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- /**
- * Created by gilbertojimenezorench on 10/14/16.
- */
- public class ConnectionClass {
- String ip = "mysqldb.capscbgbnhob.us-west-2.rds.amazonaws.com:3306";
- String classs = "net.sourceforge.jtds.jdbc.Driver";
- String db = "mysqldb";
- String un = "poastgres";
- String password = "password0987";
- @SuppressLint("NewApi")
- public Connection CONN() {
- StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
- .permitAll().build();
- StrictMode.setThreadPolicy(policy);
- Connection conn = null;
- String ConnURL = null;
- try {
- Class.forName(classs);
- ConnURL = "jdbc:jtds:sqlserver://" + ip + ";"
- + "databaseName=" + db + ";user=" + un + ";password="
- + password + ";";
- conn = DriverManager.getConnection(ConnURL);
- } catch (SQLException se) {
- Log.e("ERRO", se.getMessage());
- } catch (ClassNotFoundException e) {
- Log.e("ERRO", e.getMessage());
- } catch (Exception e) {
- Log.e("ERRO", e.getMessage());
- }
- return conn;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement