java ¶¨Ê±±¸·ÝposgreSQLÊý¾Ý¿â
Ê×ÏÈÎÒÃÇÒªÏÈдһ¸ö±¸·ÝÀà
BackupDb.java
´úÂëÈçÏ£º
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class BackupDb {
public BackupDb() {
}
public String backup() throws IOException {
BufferedWriter mBufWriter = null;
//½¨Á¢Ò»¸öBackupDb.batÎļþ
FileWriter fileWriter = new FileWriter("BackupDb.bat");
mBufWriter = new BufferedWriter(fileWriter);
/*
* °ÑÊý¾Ý¿â±¸·Ý·½·¨Ð´ÈëBackupDb.batÎļþÖС£
* BackupDbUrl ÊÇÊý¾Ý¿â±¸·ÝÃüÁî¡£
* pg_dump.exe -U postgres -E utf8 test ±¸·ÝÊý¾Ý¿âÃüÁî¡£
* —U postgres Êý¾Ý¿âÓû§Ãû -E utf8 É趨×Ö·û±àÂë¸ñʽ¡£test Êý¾Ý¿âÃû
* BackupDbName ±¸·ÝÎļþËù´æĿ¼ºÍÃû³Æ£¬ÎÒÊÇÒÔ±¸·Ýʱ¼äÃüÃû¡£
*/
String BackupDbUrl = "d:\\PostgreSQL8\\bin\\pg_dump.exe -U postgres -E utf8 test >";
//ȡϵͳʱ¼ä
Date NowTimes = new Date();
//½«Ê±¼ä¸ñʽ»¯³ÉyyMMddhhmmss(ÄêÔÂÈÕʱ·ÖÃë)£¬ÀýÈç200805010043 2008Äê5ÔÂ1ÈÕ0µã43·Ö¡£
SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
String BackupDbName = "d:\\" + sdf.format(NowTimes) + ".sql";
mBufWriter.write(BackupDbUrl);
mBufWriter.write(BackupDbName);
mBufWriter.newLine();
mBufWriter.flush();
mBufWriter.close();
try {
Runtime.getRuntime().exec("BackupDb.bat"); //Ö´ÐÐBackupDb.batÎļþ½øÐб¸·ÝÊý¾Ý¿â
} catch (Exception e) {
e.printStackTrace();
}
return BackupDbName;
}
}
È»ºóÎÒÃÇÔÚ´´½¨Ò»¸ötimerÀ࣬ÓÃÀ´¶¨Ê±±¸·Ýʱ¼ä
TimerUse.java
´úÂëÈçÏ£º
package yifeng.com.org;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.*;
public class TimerUse {
public static void m
Ïà¹ØÎĵµ£º
Äã¾õµÃ×Ô¼ºÊÇÒ»¸öJavaר¼ÒÂð£¿ÊÇ·ñ¿Ï¶¨×Ô¼ºÒѾȫÃæÕÆÎÕÁËJavaµÄÒì³£´¦Àí»úÖÆ£¿ÔÚÏÂÃæÕâ¶Î´úÂëÖУ¬ÄãÄܹ»Ñ¸ËÙÕÒ³öÒì³£´¦ÀíµÄÁù¸öÎÊÌâÂð£¿
OutputStreamWriter out = ...
java.sql.Connection conn = ...
try { // ¢É
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery(
"selec ......
´«ÖDz¥¿ÍJAVAÅàѵstruts2ѧϰ±Ê¼Ç Ç°Á½ÌìÎÒÏÝÈëÁËstruts2ÔÀíµÄÄàÌ·Öв»¿É×Ô°ÇÁË£¬ÕâÖָоõÏ൱²»´í£¬µ«ÊÇÎÒ¸öÈË»¹ÊǸоõ»ù´¡Èç¹û²»ÊǺܺõĻ°£¬Ç§Íò²»ÒªÏÝÈ룬ÒòΪÕâÑùµÄ»°£¬ºÜÓпÉÄÜÈÃÒ»¸öÈ˱äµÃûÓÐÐÅÐÄ£¬»¹ºÃÎÒÊÇÒ»¸öÐÄÀí»¹´í²»´íµÄÈË£¬ËùÒԺܿì¾Í×ßÁ˳öÀ´¡£ËùÒÔ£¬ÎҵĸöÈ˸оõ»¹ÊÇ£¬ÏÈÕÆÎÕ»ù´¡£¬È»ºóÔÚÈ¥Àí½âÔÀí°É£¬Ò ......
ÔËÓüÓÃܼ¼Êõ±£»¤JavaÔ´´úÂë
ÄÚÈÝ£º
Ò»¡¢ÎªÊ²Ã´Òª¼ÓÃÜ£¿
¶þ¡¢¶¨ÖÆÀà×°ÈëÆ÷
Èý¡¢¼ÓÃÜ¡¢½âÃÜ
ËÄ¡¢Ó¦ÓÃʵÀý
Îå¡¢×¢ÒâÊÂÏî
²Î¿¼×ÊÔ´
Java³ÌÐòµÄÔ´´úÂëºÜÈÝÒ×±»±ðÈË
͵¿´¡£Ö»ÒªÓÐÒ»¸ö·´±àÒëÆ÷£¬ÈκΠ......
×òÌìÓиöÅóÓÑÎÊÎÒ£¬Ñ§µÃ»á²»,°³ËµÑ§µÄ»á£¡
ºóÀ´ËûÓÖÎÊÎÒ£¬ËûÈç¹ûѧµÄ»°£¬Ñ§µÄ»áѧ²»»á£¬°³ËµÖ»Òª²»±¿µ°£¬°ÑÐÄ˼·ÅÔÚjavaÉÏ£¬¾ÍÒ»¶¨Ñ§µÄ»á£¡
ʱ¼äÒ»Ö±¹ýµÄ¶¼ºÜ¿ì£¬Ã¿¸öÈËÄÜ°ÑÎÕµÄÒ²Ö»ÓнñÌ죬ËùÒÔ¼´Ê¹À§ÄÑÔٶֻ࣬ÓдËʱ´Ë¿Ì×Ô¼ºÔÚ²»Í£µÄŬÁ¦¡£
ÄÄÅÂÏñÎÏÅ£Ò»ÑùµÄÇ°½ø£¬Ò²Ò»¶¨Óгɹ¦µÄÒ»Ì죬¾ÍÅÂ×Ô¼º·ÅÆú£¬ÅÂ×Ô¼ºÃ»ÓÐÐÅÐÄ£ ......