import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class MainActivity extends AppCompatActivity {
String url = "jdbc:postgres://тут правильный url";
String user = "юзер правильно указан";
String password = "пароль тоже правильно указан";
Connection conn = null;
Statement stat = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection(url, user, password);
stat = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
conn.setAutoCommit(false);
} catch (ClassNotFoundException e) {
Toast.makeText(MainActivity.this, R.string.no_posgressql_driver, Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (SQLException e) {
Toast.makeText(MainActivity.this, R.string.no_connect, Toast.LENGTH_LONG).show();
e.printStackTrace();
}
String url = "jdbc:postgres://тут правильный url";
String user = "юзер правильно указан";
String password = "пароль тоже правильно указан";