log4j 记录日志放在oracle中
一个db类 类似于jdbc的驱动和链接配置
package com.assi;
import org.apache.log4j.jdbc.JDBCAppender;
public class DB extends JDBCAppender {
public DB(){
this.setDriver("oracle.jdbc.driver.OracleDriver");
this.setURL("jdbc:oracle:thin:@172.18.220.10:1521:orcl");
this.setUser("log");
this.setPassword("log");
}
}
具体写日志的类 //没有注释 代码比较简单
package com.assi;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
public class CataLogs extends DB {
private DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
private Logger logger;
public CataLogs(){
logger=Logger.getLogger(CataLogs.class.getName());
}
//自动执行的
protected void execute(String sql){
Connection con=null;
PreparedStatement stmt=null;
try{
con=getConnection();
stmt=con.prepareStatement(this.getSql());
stmt.execute();
}
catch(Exception e){
e.printStackTrace();
&
相关文档:
您如果熟悉Oracle数据库,我想您对Thomas Kyte的大名一定不会陌生。Tomas主持的asktom.oracle.com网站享誉Oracle界数十年,绝非幸致。最近在图书馆借到这位Oracle绝顶高手编著的《Expert Oracle Database Architecture-9i and 10g programming Techniques and Solutions》,翻阅之下,果然盛名无虚,虽然说不上字字珠玑,但 ......
1. use database as archive log mode and set archive dest location
alter system set LOG_ARCHIVE_DEST_1 = 'LOCATION=/u04/arch/orcl' scope=spfile;
2. configuration retention days/size/distination
ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=43200; --30 days
ALTER SYSTEM SET db_recovery_file_dest_ ......
一.按英文字母排序:
select * from table order by nlssort(name,'NLS_SORT=schinese_pinyin_M');
二. 写一个SQL语句,查询选修了5门课程的学生学号和姓名(9分钟)
答:SQL语句如下:
select stu.sno, stu.sname
from student stu
where (select count(*) from s ......
1、触发器的概念
触发器也是一种带名的PL/SQL块。触发器类似于过程和函数,因为它们都是拥有声明、执行和异常处理过程的带名PL/SQL块。与包类似,触发器必须存储在数据库中并且不能被块进行本地化声明。
对于触发器而言,当触发事件发生的时候就会显式地执行该触发器,并且触发器不接受参数。
创建触发器的语法� ......
oracle and sqlsever 常用数学函数对比
数学函数
1.绝对值
S:select abs(-1) value
O:select abs(-1) value from dual
2.取整(大)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.取整(小)
S:select floor(-1.001) value ......