
package ejerciciojdbc5;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class EjercicioJDBC5 {

    public static void main(String[] args) {
        try {
              //    CONEXION MySQL
              Class.forName("com.mysql.jdbc.Driver");
              Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/biblioteca", "root", ""); 
              String sql = "CREATE TABLE clientes                           " +
                           "(                                               " +
                           "    dni        CHAR(10),                        " +
                           "    nombre     VARCHAR(40),                     " +
                           "    prioridad  INT,                             " +
                           "    saldo      DOUBLE,                          " +
                           "    CONSTRAINT pk_clientes PRIMARY KEY(dni)     " + 
                           ")                                               ";               
/*              
              //    CONEXION Oracle
              Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL", "scott", "tiger");  

              String sql = "CREATE TABLE clientes                           " +
                           "(                                               " +
                           "    dni        CHAR(10),                        " +
                           "    nombre     VARCHAR(40),                     " +
                           "    prioridad  NUMBER,                          " +
                           "    saldo      NUMBER,                          " +
                           "    CONSTRAINT pk_clientes PRIMARY KEY(dni)     " + 
                           ")                                               ";
*/            
              Statement statement = connection.createStatement();
              statement.executeUpdate(sql);
              connection.close();
         } catch(Exception e){
            e.printStackTrace();           
         }     
    }   
}
