Guest User

Untitled

a guest
May 26th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. private static final String DDBC_DRIVER = "com.mysql.jdbc.Driver";
  2. private static final String DB_URL = "jdbc:mysql://localhost:3306";
  3.  
  4. private static final String USER = "root";
  5. private static final String PASS = "1234";
  6.  
  7. public static void conecta() throws ClassNotFoundException, SQLException {
  8. try {
  9. conexion = DriverManager.getConnection(DB_URL, USER, PASS);
  10.  
  11. stmt = conexion.createStatement();
  12.  
  13.  
  14. } catch (SQLException se) {
  15. se.printStackTrace();
  16. } catch (Exception e) {
  17. e.printStackTrace();
  18. }
  19. }
  20.  
  21. public void llenarComboBD() throws SQLException{
  22. MySQL.ejecutaConsulta("show databases");
  23. while(MySQL.getRs().next()){
  24. System.out.println(MySQL.getRs().getString(0));
  25. }
  26. }
  27.  
  28. public static void ejecutaConsulta(String consulta) {
  29. try {
  30. rs = stmt.executeQuery(consulta);
  31. meta = rs.getMetaData();
  32. } catch (SQLException ex) {
  33. Logger.getLogger(MySQL.class.getName()).log(Level.SEVERE, null, ex);
  34. }
  35. }
  36.  
  37. public void llenarComboBD() throws SQLException, ClassNotFoundException{
  38. MySQL.conecta("jdbc:mysql://localhost:3306/", "root", "1234");
  39. MySQL.ejecutaConsulta("show databases");
  40. ResultSet rs = MySQL.getRs();
  41. //MySQL.getMeta();
  42.  
  43. while(rs.next()){
  44. //String bd = rs.getString(1);
  45. jcBD.add());
  46. }
  47.  
  48. }
  49.  
  50. while(rs.next()){
  51. //String bd = rs.getString(1);
  52. jcBD.add());
  53. }
Add Comment
Please, Sign In to add comment