Advertisement
Guest User

Untitled

a guest
Apr 12th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. /** Called when the activity is first created. */
  2. String str="new";
  3. static ResultSet rs;
  4. static PreparedStatement st;
  5. static Connection con;
  6.  
  7. @Override
  8. protected void onCreate(Bundle savedInstanceState) {
  9. super.onCreate(savedInstanceState);
  10. setContentView(R.layout.activity_main);
  11.  
  12. final TextView tv=(TextView)findViewById(R.id.user);
  13.  
  14. try
  15. {
  16. Class.forName("com.mysql.jdbc.Driver");
  17. con= (Connection) DriverManager.getConnection("jdbc:mysql://88.88.88.88:3306/BaseDatos","Usuario","Contraseña");
  18.  
  19. st=con.prepareStatement("select Salario from ofertas where Id=4");
  20. rs=st.executeQuery();
  21. while(rs.next())
  22. {
  23. str=rs.getString(2);
  24. }
  25. tv.setText(str);
  26. setContentView(tv);
  27. }
  28. catch(Exception e)
  29. {
  30. tv.setText("Error");
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement