Advertisement
SrJefers_Loading

conexion

Oct 10th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1.  
  2. public class conexion {
  3. public String USERNAME = "root";
  4. public String PASSWORD = "jeferson";
  5. public String HOST = "localhost";
  6. public String PORT = "3306";
  7. public String DATABASE = "kevin_bd";
  8. public String CLASSNAME = "com.mysql.jdbc.Driver";
  9. public String URL = "jdbc:mysql://"+HOST+":"+PORT+"/"+DATABASE+"?useSSL=false";
  10. private Connection co;
  11. protected Statement st;
  12. public conexion(){
  13. try{
  14. Class.forName(CLASSNAME);
  15. co = DriverManager.getConnection(URL, USERNAME, PASSWORD);
  16. }catch(ClassNotFoundException cnex){
  17. System.out.println(cnex.getMessage());
  18. }
  19. catch(SQLException exsql){
  20. System.out.println(exsql.getMessage());
  21. }
  22. }
  23. public Statement getStmt(){
  24. return this.st;
  25. }
  26.  
  27. public Connection getconexion(){
  28. return co;
  29. }
  30. public static void main(String[] args){
  31. conexion con = new conexion();
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement