当前位置:网站首页>连接orcale
连接orcale
2022-04-23 06:15:00 【山顶看数据】
package com.asiniafo.dpi_new.dpi.utils;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
* 连接oracle
*/
public class DBUtilSjzx {
private static String driver = "oracle.jdbc.driver.OracleDriver";
private static String url = "jdbc:oracle:thin:@ip:端口:数据库名";
private static String username = "";
private static String password = "";
public static Connection getConnection() {
Connection con = null;
try {
Class.forName(driver);
con = DriverManager.getConnection(url,username,password);
return con;
}catch (Exception e){
e.printStackTrace();
}
return con;
}
/**
* 关闭oracle数据库连接
*/
public static void close(Connection con, PreparedStatement pstmt, ResultSet rs){
//关闭rs
try {
if (rs != null && !(rs.isClosed())){
rs.close();
}
}catch (Exception e){
e.printStackTrace();
}
//关闭PreparedStatement
try {
if (pstmt != null && !(pstmt.isClosed())){
pstmt.close();
}
}catch (Exception e ){
e.printStackTrace();
}
//关闭Connection
try {
if (con != null && !(con.isClosed())){
con.close();
}
}catch (Exception e){
e.printStackTrace();
}
}
}
版权声明
本文为[山顶看数据]所创,转载请带上原文链接,感谢
https://blog.csdn.net/li1579026891/article/details/122448895
边栏推荐
猜你喜欢
随机推荐
1.1 pytorch and neural network
Infrared sensor control switch
基于openmv的无人机Apriltag动态追踪降落完整项目资料(labview+openmv+apriltag+正点原子四轴)
Visual studio 2019 installation and use
AUTOSAR从入门到精通100讲(八十三)-BootLoader自我刷新
MySQL installation and configuration - detailed tutorial
面试总结之特征工程
机器视觉系列(02)---TensorFlow2.3 + win10 + GPU安装
FATFS FAT32学习小记
PyTorch 21. PyTorch中nn.Embedding模块
RISCV MMU 概述
SHA512/384 原理及C语言实现(附源码)
画 ArcFace 中的 margin 曲线
AUTOSAR从入门到精通100讲(八十六)-UDS服务基础篇之2F
Mysql database installation and configuration details
x86架构初探之8086
【点云系列】Pointfilter: Point Cloud Filtering via Encoder-Decoder Modeling
Raspberry Pie: two color LED lamp experiment
Paddleocr image text extraction
自组网灵活补盲|北峰油气田勘测解决方案