Guest User

Untitled

a guest
Mar 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public Connection xconecta(){
  2.  
  3. try {
  4. Class.forName("oracle.jdbc.driver.OracleDriver");
  5. con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","SYSTEM","12marzo1996");
  6.  
  7. if (con!=null)
  8. {
  9. System.err.println("CONECTADO");
  10. }
  11. else
  12. {
  13. System.err.println("Error");
  14. }
  15. return con;
  16. } catch (ClassNotFoundException | SQLException e) {
  17. System.err.println(e.getMessage());
  18. return null;
  19. }
  20. }
  21.  
  22. public void INGRESAR(){
  23. try {
  24. pst=con.xconecta().prepareStatement("insert into EJEMPLO
  25. values(?,?,?)");
  26. pst.setInt(1, 1);
  27. pst.setString(2, "Jose");
  28. pst.setString(3, "Castillo");
  29. pst.execute();
  30. } catch (SQLException e)
  31. {
  32. System.out.println(e.getMessage());
  33. }
  34.  
  35. }
Add Comment
Please, Sign In to add comment