Conexion Java - Oracle 11g
package Sql;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;
public class Conexion {
//var conexion
private Connection cone=null;
//funcion conexion
public Connection getConnection() {
try{
Class.forName("oracle.jdbc.OracleDriver");
String url="jdbc:oracle:thin:@localhost:1521:XE";
String user="ventas";
String pwd="123";
cone = DriverManager.getConnection(url, user, pwd);
if (cone!=null){
JOptionPane.showMessageDialog(null, "Conexion Satisfactoria Oracle 11g XE");
}
}catch(SQLException ex){
JOptionPane.showMessageDialog(null, "Error Conexion: " + ex.getMessage());
}catch(Exception e){
JOptionPane.showMessageDialog(null, "Error Driver: " + e.getMessage());
}
return cone;
}
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;
public class Conexion {
//var conexion
private Connection cone=null;
//funcion conexion
public Connection getConnection() {
try{
Class.forName("oracle.jdbc.OracleDriver");
String url="jdbc:oracle:thin:@localhost:1521:XE";
String user="ventas";
String pwd="123";
cone = DriverManager.getConnection(url, user, pwd);
if (cone!=null){
JOptionPane.showMessageDialog(null, "Conexion Satisfactoria Oracle 11g XE");
}
}catch(SQLException ex){
JOptionPane.showMessageDialog(null, "Error Conexion: " + ex.getMessage());
}catch(Exception e){
JOptionPane.showMessageDialog(null, "Error Driver: " + e.getMessage());
}
return cone;
}
}
Comentarios