操作失误绝对不可以再次发生!20080818
自我介绍
切换风格
订阅我的Blog
博客日历
文章归档...
最新发表...
博客统计...
网站链接...
资源
===========================================================
the logbook of mysql getting
===========================================================

the methord of getting the ldiary book!!

1,find the file named MySQLbinmysqld-nt.exe and execute the order:mysqld-nt.exe --log

2,restart the mysql server

3,open the log file named the computer name+.log

you can get the all the log of sql orders

4,if you want to get the only update and delete insert orders

1>create the java file

/**
* @(#)File_exec.java
*
*
* @author
* @version 1.00 2008/2/27
*/
import java.io.File;
import java.io.*;
public class File_exec {

/**
* Creates a new instance of <code>File_exec</code>.
*/
public File_exec() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args)throws java.io.IOException,java.lang.Exception {
ReadFile("");
System.out.println("this is my test"+ReadFileName(""));
}
public static void writeFile(String fileName, String content) throws Exception {
File f = new File(fileName);
if (f.exists()) {
f.delete();
}
f.createNewFile();
FileWriter fileWriter = new FileWriter(f);
PrintWriter writer = new PrintWriter(fileWriter);
writer.write(content);
writer.flush();
writer.close();
}
public static void DelFile(String fileName){
File f = new File(fileName);
if (f.exists()) {
f.delete();
}
}
public static void CreateFile(String filename)throws java.io.IOException{
File f=new File("c:myoa_logstest.txt");
if (!f.exists()){
try {
f.createNewFile();
}
catch (IOException ex) {
ex.printStackTrace();
}

}


}
//这样可以把内容直接到添加到文件的未部!!
//添加rn可以换行!!!!
public static boolean wFile(String file, String str, boolean bl) {
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(file, bl));
bw.write(str);
bw.flush();
bw.close();
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}

public static void ReadFile(String ff){
//File f = new File("c:myoa_logstest.txt");
File f = new File(ReadFileName(""));
String[] id = new String[10000];
String[] data = new String[10000];
String[] str = new String[2];
String temp = null;
int i = 0;
int rows=0;
int rowss=ReadFileRow("");
//删除文件
DelFile("c:myoa_logsnew_data.txt");
try {
BufferedReader buffer = new BufferedReader(new FileReader(f));
while ( (temp = buffer.readLine()) != null) {
rows+=1;
if (rows>rowss){//等一下要做为参数进行数据的控制!!!

int bs;
bs=temp.indexOf("UPDATE");
if (bs>0) {
wFile("c:myoa_logsnew_data.txt","rn"+temp.substring(22),true);
}
bs=temp.indexOf("DELETE");
if (bs>0) {
wFile("c:myoa_logsnew_data.txt","rn"+temp.substring(22),true);
}
bs=temp.indexOf("INSERT");
if (bs>0) {
wFile("c:myoa_logsnew_data.txt","rn"+temp.substring(22),true);
}
}
}

wFile("c:myoa_logsrows_info.txt","rn"+String.valueOf(rows),true);
}
catch (FileNotFoundException ex) {
// System.out.println("File:" + ex);
}
catch (IOException ex) {
// System.out.println("IO:" + ex);
}
}


public static int ReadFileRow(String ff){
int re=0;
//File f = new File("c:myoa_logstest.txt");
File f = new File("c:myoa_logsrows_info.txt");
String[] id = new String[10000];
String[] data = new String[10000];
String[] str = new String[2];
String temp = null;
int i = 0;
int rows=0;
try {
BufferedReader buffer = new BufferedReader(new FileReader(f));
while ( (temp = buffer.readLine()) != null) {
re=Integer.parseInt(temp);
// System.out.println(temp);
}
//对文件的内容进行基本的判断!!!
}
catch (FileNotFoundException ex) {
System.out.println("File:" + ex);
}
catch (IOException ex) {
System.out.println("IO:" + ex);
}
return re;
}
public static String ReadFileName(String ff){
String re="";
//File f = new File("c:myoa_logstest.txt");
File f = new File("c:myoa_logsfilename.txt");
String[] id = new String[10000];
String[] data = new String[10000];
String[] str = new String[2];
String temp = null;
int i = 0;
int rows=0;
try {
BufferedReader buffer = new BufferedReader(new FileReader(f));
while ( (temp = buffer.readLine()) != null) {
re=temp;
// System.out.println(temp);
}
//对文件的内容进行基本的判断!!!
}
catch (FileNotFoundException ex) {
System.out.println("File:" + ex);
}
catch (IOException ex) {
System.out.println("IO:" + ex);
}
return re;
}
}

2>creteat the file you can get the logs

3>if you want to get then soft for logging

please write a emal to me!


imlihj2007 发表于:2008.02.29 09:44 ::分类: ( java ) ::阅读:(51次) :: 评论 (0) :: 引用 (0)