Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class ClientPersist {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- try {
- Class.forName("com.mysql.jdbc.Driver");
- Connection conn;
- conn = DriverManager.getConnection(
- "jdbc:mysql://localhost/classicmodels?user=classicmodels&password=classicmodels");
- Statement stmt;
- stmt = conn.createStatement();
- ResultSet rs = stmt.executeQuery("select * from Produit");
- while (rs.next()) {
- System.out.println(rs.getInt("empno") + ", " +
- rs.getString("ename") + ", " + rs.getInt("deptno"));
- }
- stmt.close();
- conn.close();
- } catch (SQLException e) {
- System.out.println("A database error occurred:" + e.getMessage());
- } catch (ClassNotFoundException e) {
- System.out.println("Driver not found: " + e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement