Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static final String DDBC_DRIVER = "com.mysql.jdbc.Driver";
- private static final String DB_URL = "jdbc:mysql://localhost:3306";
- private static final String USER = "root";
- private static final String PASS = "1234";
- public static void conecta() throws ClassNotFoundException, SQLException {
- try {
- conexion = DriverManager.getConnection(DB_URL, USER, PASS);
- stmt = conexion.createStatement();
- } catch (SQLException se) {
- se.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public void llenarComboBD() throws SQLException{
- MySQL.ejecutaConsulta("show databases");
- while(MySQL.getRs().next()){
- System.out.println(MySQL.getRs().getString(0));
- }
- }
- public static void ejecutaConsulta(String consulta) {
- try {
- rs = stmt.executeQuery(consulta);
- meta = rs.getMetaData();
- } catch (SQLException ex) {
- Logger.getLogger(MySQL.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- public void llenarComboBD() throws SQLException, ClassNotFoundException{
- MySQL.conecta("jdbc:mysql://localhost:3306/", "root", "1234");
- MySQL.ejecutaConsulta("show databases");
- ResultSet rs = MySQL.getRs();
- //MySQL.getMeta();
- while(rs.next()){
- //String bd = rs.getString(1);
- jcBD.add());
- }
- }
- while(rs.next()){
- //String bd = rs.getString(1);
- jcBD.add());
- }
Add Comment
Please, Sign In to add comment