Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ConnectionDB {
- String ip = "192.168.1.103";
- String classs = "net.sourceforge.jtds.jdbc.Driver";
- String db = "Andro";
- String un = "abc";
- String password = "1";
- @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;
- }
- }
- ConnectionDB con=new ConnectionDB();
- if (!TextUtils.isEmpty(password) &&!TextUtils.isEmpty(email)) {
- try {
- if (con == null) {
- alertDialog.setMessage("Cannot Access To Server");
- } else {
- String query = "Select * from Partner where lower(username)=lower('" + email + "') and password=N'" + password + "'";
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery(query);
- if (rs.next()) {
- alertDialog.setMessage("Success");
- } else {
- alertDialog.setMessage("Fail");
- }
- }
- } catch (Exception ex) {
- z = "Exceptions";
- }
- }
Add Comment
Please, Sign In to add comment