oracleºÍMysqlÁ¬½ÓÊý¾Ý¿â
Mysql·½Ê½£º
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class MysqlDB {
private String strClass = "com.mysql.jdbc.Driver";
private String strDriver = "jdbc:mysql://localhost:3306/s_smdb";
private String strUser = "root";
private String strPwd = "123";
private Connection conn = null;
private Statement stmt = null;
private ResultSet rs = null;
private static CDBAccess instance = null;
private CDBAccess() throws ClassNotFoundException, SQLException{
Class.forName(strClass);
conn = DriverManager.getConnection(strDriver,strUser,strPwd) ;
}
public static CDBAccess getInstance() throws ClassNotFoundException, SQLException{
if(instance == null){
instance = new CDBAccess();
}
return instance;
}
public ResultSet executeQuery(String strsql) throws SQLException{
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(strsql);
return rs;
}
public int executeUpdate(String strsql) throws SQLException{
int i = 0;
stmt = conn.createStatement();
i = stmt.executeUpdate(strsql);
return i;
}
public void close() throws SQLException{
if(rs != null){
rs.close();
}
if(stmt != null){
stmt.close();
}
if(conn != null){
conn.close();
}
if(instance != null){
instance = null;
}
}
}
Oracle·½Ê½£º
package util;
import java.sql.Connection;
import java.sql.
Ïà¹ØÎĵµ£º
Ò»¡¢¸ÅÊö
¡¡¡¡Ê¼þµ÷¶ÈÆ÷ÊÇÔÚ MySQL 5.1 ÖÐÐÂÔöµÄÁíÒ»¸öÌØÉ«¹¦ÄÜ£¬¿ÉÒÔ×÷Ϊ¶¨Ê±ÈÎÎñµ÷¶ÈÆ÷£¬È¡´ú²¿·ÖÔÏÈÖ»ÄÜÓòÙ×÷ϵͳÈÎÎñµ÷¶ÈÆ÷²ÅÄÜÍê³ÉµÄ¶¨Ê±¹¦>ÄÜ¡£ÀýÈ磬Linux ÖÐµÄ crontabe Ö»Äܾ«È·µ½Ã¿·ÖÖÓÖ´ÐÐÒ»´Î£¬¶ø MySQL µÄʼþµ÷¶ÈÆ÷Ôò¿ÉÒÔʵÏÖÿÃëÖÓÖ´ÐÐÒ»¸öÈÎÎñ£¬ÕâÔÚһЩ¶ÔʵʱÐÔÒª>Çó½Ï¸ßµÄ»·¾³Ï¾ͷdz£ÊµÓÃÁ ......
apacheµÄ¾²Ì¬/¶¯Ì¬±àÒëÔÚapache+php+mysqlµÄÓ¦ÓÃ
ÎÒÏë´ó¼ÒÓв»ÉÙ¶¼³É¹¦ÊµÏÖapache+php+mysql£¬ÍøÉϵÄÎÄÕÂÒ²Óв»ÉÙ£¬µ«ÎÒ·¢ÏÖ²»ÉÙÎÄÕ¶¼ÊdzÀ´³È¥£¬²¢ÇÒ
ûÓÐ˵Ã÷°×±àÒëµÄ·½Ê½£¬ÓеÄË÷ÐÔapache1.3µÄ±àÒë·½·¨Ô·â²»¶¯µÄ°á¹ýÀ´Ì×ÔÚapache2.0£¬ÏÔÈ»Îóµ¼Ò»Ð©²ËÄñ £¡
ÎÒ½ñÌì¾ÍÒÔapache+mysql+php˵һϾ²Ì¬±àÒëºÍDSO¶¯Ì¬±à ......
Ò»¡¢MySQL »ñµÃµ±Ç°ÈÕÆÚʱ¼ä º¯Êý
1.1 »ñµÃµ±Ç°ÈÕÆÚ+ʱ¼ä£¨date + time£©º¯Êý£ºnow()
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+
³ýÁË now() º¯ÊýÄÜ»ñµÃµ±Ç°µÄÈÕÆÚʱ¼äÍ⣬MySQL Öл¹ÓÐÏÂÃæµÄº¯Êý£º
......
¹ú¶¼ºÅÂëÊý¾Ý¿âÉè¼ÆËµÃ÷
V1
Îĵµ±ä¸ü¼Ç¼
ÐòºÅ
±ä¸üÄÚÈÝ˵Ã÷
°æ±¾ºÅ
°æ±¾ÈÕÆÚ
Ö´±ÊÈË
1
³õ¸å
V ......
Æäʵ£¬ÕâÆª¶ÌÎÄ£¬ÎÒÔç¾ÍÓ¦¸ÃдÁË¡£ÒòΪ£¬java´æ´¢¹ý³Ì½ñºóÔÚ¸÷´óÊý¾Ý¿â³§ÉÌÖÐÔ½À´Ô½Á÷ÐУ¬¹¦ÄÜÒ²Ô½À´Ô½Ç¿´ó¡£ÕâÀïÒÔOracleΪÀý£¬½éÉÜÒ»ÏÂjava´æ´¢¹ý³ÌµÄ¾ßÌåÓ÷¨¡£
Ò»¡¢ÈçºÎ´´½¨java´æ´¢¹ý³Ì£¿
ͨ³£ÓÐÈýÖÖ·½·¨À´´´½¨java´æ´¢¹ý³Ì¡£
1. ʹÓÃoracleµÄsqlÓï¾äÀ´´´½¨£º
e.g. ʹÓÃcreate or replace and compile java source ......