Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class MySqlCode {
- public static void main(String[] args) throws Exception {
- String usuario = "user";
- String password = "pass";
- String url = "jdbc:mysql://servidor:3306/db";
- try (Connection conexion = DriverManager.getConnection(url, usuario, password);
- PreparedStatement ps = conexion.prepareStatement("select * from tbl");
- ResultSet rs = ps.executeQuery()) {
- while (rs.next()) {
- System.out.printf(
- "%s-%s%n",
- rs.getString("col1"),
- rs.getString("col2"));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement