JDBC配置文件properties
来源:互联网 发布:虚拟号码发短信软件 编辑:程序博客网 时间:2024/06/06 18:57
package a1;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
public class a2 {
public static Connection getconn() throws Exception{
Properties props = new Properties();
Reader is;
try {
is = new FileReader("C:/Users/Administrator/Desktop/a.txt");
props.load(is);
String a = props.getProperty("co");
String b = props.getProperty("url");
String c = props.getProperty("u");
String d = props.getProperty("p");
try {
Class.forName(a);
System.out.println("驱动链接成功");
Connection conn1 = DriverManager.getConnection(b,c,d);
System.out.println("数据库连接成功");
return conn1;
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("失败了");
}
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return null;
}
}
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
public class a2 {
public static Connection getconn() throws Exception{
Properties props = new Properties();
Reader is;
try {
is = new FileReader("C:/Users/Administrator/Desktop/a.txt");
props.load(is);
String a = props.getProperty("co");
String b = props.getProperty("url");
String c = props.getProperty("u");
String d = props.getProperty("p");
try {
Class.forName(a);
System.out.println("驱动链接成功");
Connection conn1 = DriverManager.getConnection(b,c,d);
System.out.println("数据库连接成功");
return conn1;
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("失败了");
}
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return null;
}
}
阅读全文
0 0
- JDBC配置文件properties
- JDBC学习02-properties配置文件
- Spring 使用配置文件读取jdbc.properties
- Spring使用配置文件读取jdbc.properties
- Spring使用配置文件读取jdbc.properties
- spring配置文件中配置jdbc.properties 文件
- 在配置文件中读取:jdbc.properties文件
- JDBC链接之读取配置文件properties
- spring中jdbc.properties配置文件用法
- 怎样读取jdbc.properties配置文件的信息
- 如何从properties配置文件中对去jdbc链接配置
- Spring+mybatis+maven整合过程加载配置文件jdbc.properties
- jdbc基础 (二) 通过properties配置文件连接数据库
- JDBC中关于封装和读取配置文件properties的问题
- 从零开始学JDBC--1.9 代码抽取--使用Properties读取配置文件
- spring配置文件读取jdbc.properties的配置信息
- 从零开始学JDBC--1.9 代码抽取--使用Properties读取配置文件
- MyBatis主配置文件与jdbc.properties文件结合使用
- 偏差-方差权衡(Bias-Variance Tradeoff)
- FallbackDefinitionException:fallback method wasn't found: defaultUser([class java.lang.Long])
- 一起学Kotlin(3)
- params ref out
- jquery 基本过滤器,删除table的行
- JDBC配置文件properties
- HTTP中GET方法和POST方法的区别
- redis 集群
- Android中使EditText失去焦点,edittext禁止弹出键盘
- 欢迎使用CSDN-markdown编辑器
- Hibernate一些sql
- TClientDataSet[3]: 手动建立数据集
- VScode常用插件
- 文章标题