/* * This sample shows how to list all the names from the EMP table * * It uses the JDBC thin driver. */ // You need to import the java.sql package to use JDBC import java.sql.*; class InsereVin { public static void main (String args []) throws SQLException, ClassNotFoundException { // Load the Oracle JDBC driver Class.forName ("oracle.jdbc.driver.OracleDriver"); // Connect to the database // You can put a database name after the @ sign in the connection URL. Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@ararat:1521:SIREC", "binomeXX", "io21"); // Create a PreparedStatement PreparedStatement stmt = conn.prepareStatement ("INSERT INTO VINS VALUES(?, ?,?, ?)"); // on donne des valeurs aux parametres de la requete stmt stmt.setInt(1, 200); stmt.setString(2, "Hermitage"); stmt.setInt(3, 2000); stmt.setDouble(4, 12.5); int res = stmt.executeUpdate(); if (res==1) { System.out.println("\nInsertion reussie\n"); conn.commit(); } else conn.rollback(); } }