Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package oscop;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- /**
- *
- * @author dani
- */
- public class Oscop {
- public static void main(String[] args) {
- Connection connection = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- connection = DriverManager.getConnection("jdbc:mysql://10.42.0.1:3306/user", "android", "oscop");
- String sql;
- sql = "SELECT * FROM user";
- Statement statement = connection.createStatement();
- ResultSet ps = statement.executeQuery(sql);
- while(ps.next()) {
- System.out.println(ps.getInt(1)+""+ ps.getString(2) +""+ps.getString(3));
- connection.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement