Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Connection xconecta(){
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","SYSTEM","12marzo1996");
- if (con!=null)
- {
- System.err.println("CONECTADO");
- }
- else
- {
- System.err.println("Error");
- }
- return con;
- } catch (ClassNotFoundException | SQLException e) {
- System.err.println(e.getMessage());
- return null;
- }
- }
- public void INGRESAR(){
- try {
- pst=con.xconecta().prepareStatement("insert into EJEMPLO
- values(?,?,?)");
- pst.setInt(1, 1);
- pst.setString(2, "Jose");
- pst.setString(3, "Castillo");
- pst.execute();
- } catch (SQLException e)
- {
- System.out.println(e.getMessage());
- }
- }
Add Comment
Please, Sign In to add comment