Skip to content

Instantly share code, notes, and snippets.

View jianshe's full-sized avatar

jianshe jianshe

  • 深圳平安综合金融服务有限公司上海分公司
  • 上海市浦东新区福山路455号全华信息大厦
View GitHub Profile
@jianshe
jianshe / hibernate.cfg.xml
Last active August 29, 2015 13:57
hibernate的基本配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@192.168.1.103:1521:ORCL</property>
@jianshe
jianshe / TestSelect
Last active August 29, 2015 13:57
Oracle and Java
package com.jiansheit.jdbc.oracle;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class TestSelect {
public static void main(String[] args) {
final String DRIVER = "oracle.jdbc.driver.OracleDriver";
@jianshe
jianshe / insert触发器
Created March 25, 2014 05:24
Oracle中触发器的使用
1.dbms_output.put_line()用于将变量输出到控制台上,如果没有输出可以通过set serveroutput on设置输出。
2.触发器的创建。
create or replace trigger save_before_banji
after insert on banji
for each row
begin
dbms_output.put_line('刚插入的id为:' || to_char(:new.id));
end;
/
3.使用该触发器会在插入语句后面显示:刚插入的id的值。
@jianshe
jianshe / BasicDao.java
Last active August 29, 2015 13:57
java中的反射,通过子类去创建出的父类对象中的this还是指的是子类对象。
package com.kaishengit.dao;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import javax.inject.Inject;
import org.hibernate.Criteria;
@jianshe
jianshe / web.xml
Created March 5, 2014 15:14
spring,hibernate,struts中基于注解的整合。
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- OpenSessionInView-->
<filter>
@jianshe
jianshe / UserDao.java
Last active August 29, 2015 13:57
spring与hibernate的结合
package com.kaishengit.dao;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
@jianshe
jianshe / schema
Created March 5, 2014 14:22
spring中对事务支持,以及事务的使用。
xmlns:tx="http://www.springframework.org/schema/tx"
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
<!-- 加载ClassPath中的properties文件 -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
@jianshe
jianshe / UserDao.java
Created March 5, 2014 13:40
Spring JDBC
package com.kaishengit.dao.impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import org.springframework.jdbc.core.JdbcTemplate;
@jianshe
jianshe / ApplicationContext.xml
Created March 5, 2014 13:25
spring中基于注解的Annocation的配置
<?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:aop="http://www.springframework.org/schema/aop"
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/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
@jianshe
jianshe / applicationContext.xml
Created March 5, 2014 13:19
spring中的自动注入
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Spring Bean 管理 -->
<bean id="myDao" class="com.kaishengit.dao.impl.UserDao"/>
<bean id="myDao2" class="com.kaishengit.dao.impl.UserDaoOracle"></bean>