package ;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class GetBikeInfoByOracle {
public static Connection getConn(){
Connection conn = null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:xxx.com", "mgis", "mgis");
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "root", "123");
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://192.168.8.26:5432/posttest", "postgres", "postgres");
}catch(Exception e){
e.printStackTrace();
}
return conn;
}
public static void closeConn(Connection conn){
if(conn !=null){
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public static void closeStatment(Statement stat){
if(stat !=null){
try {
stat.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public static void closeRs(ResultSet rs){
if(rs !=null){
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
Connection conn = getConn();
System.out.println("conn ---------- "+conn);
}
}