当前位置:网站首页>连接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
边栏推荐
- 城市应急管理|城市突发事故应急通信指挥调度系统
- Gephi tutorial [1] installation
- armv8m(cortex m33) MPU实战
- 主流 RTOS 评估
- Chapter 5 fundamentals of machine learning
- [8] Assertion failed: dims.nbDims == 4 || dims.nbDims == 5
- 基于Labview上位机的51单片机步进电机控制系统(上位机代码+下位机源码+ad原理图+51完整开发环境)
- Unable to determine the device handle for GPU 0000:02:00.0: GPU is lost.
- onnxruntime-gpu 1.7 出现的警告“Force fallback to CPU execution for node: Gather_191”等
- torch.where能否传递梯度
猜你喜欢
随机推荐
【点云系列】Multi-view Neural Human Rendering (NHR)
Swin transformer to onnx
【点云系列】Pointfilter: Point Cloud Filtering via Encoder-Decoder Modeling
GIS实用小技巧(三)-CASS怎么添加图例?
EMMC/SD学习小记
PyTorch 10. 学习率
基于51单片机的体脂检测系统设计(51+oled+hx711+us100)
【无标题】PID控制TT编码器电机
如何利用qemu搭建SOC protoype:80行代码实现一个Cortex M4 模拟器
Wechat applet uses wxml2canvas plug-in to generate some problem records of pictures
Unwind 栈回溯详解
Are realrange and einsum really elegant
Chapter 2 pytoch foundation 2
Visual studio 2019 installation and use
AMBA协议学习小记
AUTOSAR从入门到精通100讲(八十六)-UDS服务基础篇之2F
excel实战应用案例100讲(八)-Excel的报表连接功能
torch.where能否传递梯度
PyTorch 18. torch.backends.cudnn
imx6ull-qemu 裸机教程1:GPIO,IOMUX,I2C