Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void ConnectToDatabase() {
- try {
- String connectionUrl1 = "jdbc:sqlserver://my.no-ip.org:49159;databaseName=database;user=username;password=pw";
- Connection DbConn = null;
- Statement stmt = null;
- ResultSet rs = null;
- Log.w("Success", "Class found.");
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
- DbConn = DriverManager.getConnection(connectionUrl1);
- Log.w("Success", "Connection Established.");
- stmt = DbConn.createStatement();
- rs = stmt.executeQuery("select * from table");
- DbConn.close();
- } catch (SQLException sq) {
- displaymessage3.setText("Connection Errorn" + sq.getMessage());
- Log.w("Error connection", "" + sq.getMessage());
- } catch(Exception e){
- displaymessage4.setText("Connection Errorn" + e.getMessage());
- Log.w("Error connection", "" + e.getMessage());
- }
- }
- 03-20 22:17:03.507 1830-1830/myprogram W/Success: Class found.
- 03-20 22:17:03.517 1830-1830/myprogram W/Error connection: null
- var conn = Jdbc.getConnection('jdbc:sqlserver://my.no-ip.org:49159', 'username', 'pw');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement