Created
September 29, 2014 20:59
-
-
Save chukitow/2ade034441e523996604 to your computer and use it in GitHub Desktop.
JAVA MYSQL CONNECTION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package com.chukitow.ci.actions; | |
import java.sql.Connection; | |
import java.sql.DriverManager; | |
/** | |
* | |
* @author chukitow | |
*/ | |
public class Dbconection { | |
public Dbconection() | |
{ | |
} | |
//probando la conexion | |
public Connection Conectar() | |
{ | |
//declarando un objeto conexion; | |
Connection link=null; | |
try | |
{ | |
//cargamos el archivo de conexion | |
Class.forName("com.mysql.jdbc.Driver"); | |
//creamos el enlace | |
link= DriverManager.getConnection("jdbc:mysql://"+Database.host+"/"+Database.db+"?user="+Database.user+"&password="+Database.password+""); | |
} | |
catch(Exception e) | |
{ | |
System.err.println("Imposible database connection"); | |
} | |
//retorna el link | |
return link; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment