Compare commits
No commits in common. "1b377734dd12fc4e5d8276914800e0b421b9df18" and "409db8de50b9ae12dc593678538e59d5b6ab5a70" have entirely different histories.
1b377734dd
...
409db8de50
|
@ -14,8 +14,8 @@
|
|||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -1,42 +1,26 @@
|
|||
package mx.uv;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.sql.Connection;
|
||||
|
||||
public class Conexion {
|
||||
public static String url="mysql://root:tdPXEKculfAIumCBQirpMvZYXnrOuCbZ@monorail.proxy.rlwy.net:51101/railway";
|
||||
public static String Drivername="com.mysql.cj.jdbc.Driver";
|
||||
public static String username="root";
|
||||
public static String password="tdPXEKculfAIumCBQirpMvZYXnrOuCbZ";
|
||||
|
||||
private Connection conexion;
|
||||
String driver = "com.mysql.cj.jdbc.Driver";
|
||||
private String url = "jdbc:mysql://root:tdPXEKculfAIumCBQirpMvZYXnrOuCbZ@monorail.proxy.rlwy.net:51101/railway";
|
||||
private final String USUARIO="root";
|
||||
private final String CONTRASENA="tdPXEKculfAIumCBQirpMvZYXnrOuCbZ";
|
||||
private static Connection conexion=null;
|
||||
|
||||
public Connection obtenerConexion() throws SQLException{
|
||||
conecta();
|
||||
public static Connection getConnection(){
|
||||
try {
|
||||
Class.forName(Drivername);
|
||||
conexion = DriverManager.getConnection(url, username, password);
|
||||
} catch (SQLException e) {
|
||||
System.out.println(" SQL:" + e);
|
||||
} catch (ClassNotFoundException e){
|
||||
System.out.println("Driver:" + e);
|
||||
}
|
||||
return conexion;
|
||||
}
|
||||
|
||||
private void conecta() throws SQLException{
|
||||
try {
|
||||
Class.forName(driver);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
conexion=DriverManager.getConnection(url,USUARIO,CONTRASENA);
|
||||
}
|
||||
|
||||
public void cerrarConexion(){
|
||||
if(conexion!=null){
|
||||
try {
|
||||
if(!conexion.isClosed()){
|
||||
conexion.close();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue