Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Called when the activity is first created. */
- String str="new";
- static ResultSet rs;
- static PreparedStatement st;
- static Connection con;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- final TextView tv=(TextView)findViewById(R.id.user);
- try
- {
- Class.forName("com.mysql.jdbc.Driver");
- con= (Connection) DriverManager.getConnection("jdbc:mysql://88.88.88.88:3306/BaseDatos","Usuario","Contraseña");
- st=con.prepareStatement("select Salario from ofertas where Id=4");
- rs=st.executeQuery();
- while(rs.next())
- {
- str=rs.getString(2);
- }
- tv.setText(str);
- setContentView(tv);
- }
- catch(Exception e)
- {
- tv.setText("Error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement