javaÎÞÊý¾ÝÔ´Á¬½ÓAccessÊý¾Ý¿âʵÀý
1.Á¬½ÓÊý¾Ý¿âConnDB()Àà
package tool;
/****************************
**
**ÊôÐÔÎļþÓëÊý¾Ý¿â¾ùÔÚtool°üÏÂÃæ
**
*****************************/
/* Êý¾Ý·ÃÎÊ×é¼þ */
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class ConnDB{
private static ConnDB instance=null;
String db_driver=null;
String db_url=null;
String db_user=null;
String db_psw=null;
String db_name=null;
String proPath="conn.properties";
Connection conn=null;
public ConnDB(){
InputStream in=getClass().getResourceAsStream(proPath);
Properties prop=new Properties();
try {
prop.load(in);
db_driver=prop.getProperty("db_driver",db_driver);
db_url=prop.getProperty("db_url",db_url);
db_user=prop.getProperty("db_user",db_user);
db_psw=prop.getProperty("db_psw", db_psw);
db_name=prop.getProperty("db_name",db_name);
db_url=db_url+getDBPath();
} catch (IOException e) {
e.printStackTrace();
}
}
//»ñµÃ°²È«Á¬½Ó
public synchronized Connection getConnection(){
if(instance==null){
instance=new ConnDB();
}
return instance._getConnection();
}
//ÊÍ·Å×ÊÔ´
public static void dbClose(Connection conn,PreparedStatement ps,ResultSet rs){
try{
if(rs!=null){
rs.close();
}
if(ps!=null){
ps.close();
}
if(conn!=null){
conn.close();
}
}catch(SQLException e){
e.printStackTrace();
}
}
//´´½¨Á¬½Ó
private Connection _getConnection() {
try {
Class.forName(db_driver).newInstance();
conn=DriverManager.getConnection(db_url, db_user, db_psw);
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
//·µ»ØÊý¾Ý¿âµÄ¾ø¶Ô·¾¶
public String getDBPath(){
String dbpath=getClass().getResource(db_name).getFile();
dbpath=db
Ïà¹ØÎĵµ£º
µÚÒ»£¬Ì¸Ì¸final, finally, finalizeµÄÇø±ð¡£
final ÐÞÊηû£¨¹Ø¼ü×Ö£©Èç¹ûÒ»¸öÀà±»ÉùÃ÷Ϊfinal£¬Òâζ×ÅËü²»ÄÜÔÙÅÉÉú³öеÄ×ÓÀ࣬²»ÄÜ×÷Ϊ¸¸Àà±»¼Ì³Ð¡£Òò´ËÒ»¸öÀ಻Äܼȱ»ÉùÃ÷Ϊ abstractµÄ£¬ÓÖ±»ÉùÃ÷ΪfinalµÄ¡£½«±äÁ¿»ò·½·¨ÉùÃ÷Ϊfinal£¬¿ÉÒÔ±£Ö¤ËüÃÇÔÚʹÓÃÖв»±»¸Ä±ä¡£±»ÉùÃ÷ΪfinalµÄ±äÁ¿±ØÐëÔÚÉùÃ÷ʱ¸ø¶¨³õÖµ£¬¶øÔÚÒÔ ......
ÊÖ¶¯½¨±í£º
CREATE TABLE `excel` (
`id` int(11) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL,
`passwd` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gb2312; ×¢ÒâÊÇgb2312
È»ºóÔÚÁ¬½ÓÊý¾Ý¿âʱ¼ÓÉÏ:
useUnicode=true&characterEncoding=gb2312.
¾ÍokÀ²£¡ ......
Èý¸öѧÉúµ½Ò»¸öË®ÁúÍ·ÏÂÅŶÓÈ¡Ë®£¬ÈýÈ˶¼È¡ÍêË®ºóÒ»ÆðÀ뿪¡£
ÕâÀïÉæ¼°µ½ÈçºÎÅжÏÈý¸öÈ˶¼È¡ÍêË®¡£Èç¹ûÓÃÆÕͨµÄ¾²Ì¬³ÉÔ±£¬ÊƱػáÒªÓÃÎÞÏÞÑ»·À´µÈ´ý¡£¸üºÃµÄ°ì·¨ÊÇÓà wait-notify »úÖÆ¡£Ç°Á½¸öѧÉúÈ¡ÍêË®ºó¶¼ wait£¬×îºóÒ»¸öѧÉúÈ¡ÍêË®ºó notify£¬ÕâÑù¾ÍÄÜÒ»ÆðÀ뿪ÁË¡£ÏÂÃæÊÇ´úÂëʾÀý£º
/**
* Èý¸öѧÉúÅŶÓÈ¡Ë®£¬È¡ÍêºóÒ ......
ÔÚ¿ª·¢Ò»¸öjavaµÄ¹ÜÀíϵͳʱ£¬ÖÐÎÄÎÊÌâ³£³£À§ÈÅ×ÅÎÒÃÇ£¬¸ù¾ÝÎҵľÑ飬ÎÞ·ÇΪÏÂÃ漸ÖÖ£»
²½Öè1.oreacle ¿Í»§¶Ë»·¾³±äÁ¿µÄÐ޸ġ£
[ECP_WEB]/oracle$locale
LANG=zh_CN.gbk
LC_CTYPE="zh_CN.gbk"
LC_NUMERIC="zh_CN.gbk"
LC_TIME="zh_CN.gbk"
LC_COLLATE="zh_CN.gbk"
LC_MONETARY="zh_CN.gbk"
LC_MESSAGES="zh ......
fm.split("["); // error
-------------------
java.util.regex.PatternSyntaxException: Unclosed character class near index 0[+
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.clazz(Unknown Source)
& ......