SHOW:
|
|
- or go back to the newest paste.
1 | - | package unsch.efpis.ConexionDB; |
1 | + | package uns.ConexionDB; |
2 | ||
3 | //Importamos las siguientes clases necesarias | |
4 | import java.sql.Connection; | |
5 | import java.sql.Driver; | |
6 | import java.sql.DriverManager; | |
7 | import java.sql.SQLException; | |
8 | ||
9 | /** | |
10 | - | * @author sin_querer |
10 | + | |
11 | * @Rafa | |
12 | */ | |
13 | - | private static Connection cn = null; |
13 | + | |
14 | //Establecemos connection para conectarse a la base de datos | |
15 | private static Connection connection = null; | |
16 | - | private static String usuario = "usuarioderby"; |
16 | + | //Utilizamos localhost ya que el servidor correra en nuestra propia maquina |
17 | - | private static String contrasena = "123456"; |
17 | + | |
18 | private static String URLDerby = "jdbc:derby://localhost:1527/DBDerby"; | |
19 | //Establecemos el usuario y la contrasena para conectarnos a la base de datos | |
20 | private static String user = "userDerby"; | |
21 | - | cn = DriverManager.getConnection(URLDerby, usuario, contrasena); |
21 | + | private static String password = "12345"; |
22 | - | return cn; |
22 | + | |
23 | public static Connection getConexion() throws SQLException { | |
24 | DriverManager.registerDriver(driver); | |
25 | connection = DriverManager.getConnection(URLDerby, user, password); | |
26 | return connection; | |
27 | } | |
28 | } |