Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ConnectionHelper() {
- StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
- .permitAll().build();
- StrictMode.setThreadPolicy(policy);
- setConnection(connection);
- try {
- Class.forName("net.sourceforge.jtds.jdbc.Driver");
- setIpAddress("X.X.X.X:1433");
- setDb("XXX");
- setUserName("XX");
- setPassword("XXXX");
- setConnectionURL("jdbc:jtds:sqlserver://" + getIpAddress() + ";"
- + "databaseName=" + getDb() + ";user=" + getUserName()
- + ";password=" + getPassword() + ";");
- setConnection(DriverManager.getConnection(getConnectionURL()));
- } catch (SQLException se) {
- Log.e("ERRO", se.getMessage());
- } catch (ClassNotFoundException e) {
- Log.e("ERRO", e.getMessage());
- } catch (Exception e) {
- Log.e("ERRO", e.getMessage());
- }
- }
- public Connection getConnection() {
- return connection;
- }
- ConnectionHelper connectionHelper = new ConnectionHelper();
- CallableStatement callableStatement;
- try {
- callableStatement = connectionHelper.getConnection().prepareCall("{call MySP(?, ?, ?)}");
- callableStatement.setInt(1, X);
- callableStatement.setInt(2, X));
- callableStatement.setInt(3, X);
- callableStatement.executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement