Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author bruno
- */
- package test;
- import java.sql.*;
- public class Main {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args){
- try{
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost/prositjava1","bruno", "bruno");
- Statement stmt = con.createStatement();
- ResultSet res= stmt.executeQuery("SELECT * FROM test");
- while(res.next()){
- System.out.println("ID : " + res.getInt(1));
- System.out.println("Nom: " + res.getString(2));
- }
- System.out.println("\nInsertion d'éléments :");
- int ret = stmt.executeUpdate("INSERT INTO test VALUES (350, \"Papa Noël\")");
- System.out.println("Nbr lignes modifiés : " + ret);
- }catch(Exception e){
- System.out.println("Problème de pilote : " + e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement