spring 框架jdbc连接数据库
2024-10-21 12:56:53
user=LF
password=LF
url=jdbc:oracle:thin:@localhost:1521:orcl
driver=oracle.jdbc.driver.OracleDriver
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"> <context:property-placeholder location="classpath:jdbc.properties"/>
<bean id="connection" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="username" value="${user}"></property>
<property name="password" value="${password}"></property>
<property name="driverClassName" value="${driver}"></property>
<property name="url" value="${url}"></property>
</bean> </beans>
public class Utils_jdbc { public static void main(String[] args) { ApplicationContext ctc = new ClassPathXmlApplicationContext("applicationContext.xml"); DriverManagerDataSource dSource = (DriverManagerDataSource) ctc.getBean("connection"); try { System.out.println(dSource.getConnection());
} catch (SQLException e) {
e.printStackTrace();
} } }
最新文章
- Fedora 22中的Services and Daemons
- COGS182 [USACO Jan07] 均衡队形[RMQ]
- 图解jmeter压测http接口
- .NET跨平台之mac 下vs code 多层架构编程
- 4. Prototype(原型)
- DevExpress Ribbongallerybaritem选择性皮肤重组
- Bubble Sort [ASM-MIPS]
- Wdcp在安装memcached出现错误的解决办法
- java最全的验证类封装
- Php output buffering缓存及程序缓存
- 20145120 《Java程序设计》第7周学习总结
- 跟大家分享下今天所学到的PHP,虽然很基础,但是感觉也很重要
- DOM生成XML文档与解析XML文档(JUNIT测试)
- NSURLConnection请求时间
- Tomcat 7.0 进入项目管理页面时的密码问题
- Jquery文本框值改变事件(支持火狐、ie)
- 腾讯云实力通过工信部测评,获全国范围CDN经营许可
- element-ui,router.push到其他路由,菜单栏不会高亮对应的路由
- 最小化安装CentOS7的网卡设置
- MySQL使用select查询时,在查询结果中增加一个字段并指定固定值
热门文章
- ";=="; 与 ";is";的区别
- Dreamweaver_CS6安装与破解
- C#编程的几个建议
- ES6常用知识总结(20%的知识占80%的份额)
- 冒泡排序的JavaScript实现
- 新机器连接老机器遇到的ERROR
- centOS下 JDK的三种安装方式
- Annotation之二:@Inherited注解继承情况
- Git使用点滴记录: You have no permission to access this repo.
- 1139 First Contact