Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import android.support.v7.app.AppCompatActivity;
  2. import android.os.Bundle;
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.Statement;
  7. public class MainActivity extends AppCompatActivity {
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. setContentView(R.layout.activity_main);
  12. String url = "jdbc:mysql://database";
  13. String user = "user";
  14. String password = "pass";
  15. try {
  16. Class.forName("com.mysql.jdbc.Driver").newInstance();
  17. Connection con = DriverManager.getConnection(url, user, password);
  18. Statement st = con.createStatement();
  19. ResultSet rs = st.executeQuery("select * from table");
  20. con.close();
  21. }catch (Exception e) {
  22. e.printStackTrace();
  23. }
  24. }
  25. }
  26.  
  27. allprojects {
  28. tasks.withType(JavaCompile) {
  29. sourceCompatibility = '1.7'
  30. targetCompatibility = '1.7'
  31. }
  32.  
  33. repositories {
  34. jcenter()
  35. }
  36. }
  37.  
  38. compileOptions {
  39. sourceCompatibility JavaVersion.VERSION_1_7
  40. targetCompatibility JavaVersion.VERSION_1_7
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement