JAVA³£ÓòÙ×÷Óï¾ä ÏîÄ¿ÖеÄ×ܽáÈý
»ñµÃmysqlºÍoracleÁ´½ÓµÄÀà
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectDB {
private static final String MYSQL = "jdbc:mysql://";
private static final String ORACLE = "jdbc:oracle:thin:@";
private ConnectDB() {
}
public static Connection getInstance(String DBType, String url)
throws NoSuchDBException, SQLException
{
if ("mysql".equalsIgnoreCase(DBType))
return getMySqlConn(url);
if ("oracle".equalsIgnoreCase(DBType))
return getOracleConn(url);
return null;
}
public static void closeConn(Connection conn) {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
private static Connection getMySqlConn(String url) throws SQLException {
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
conn = DriverManager.getConnection(MYSQL + url, "root", "root");
return conn;
}
private static Connection getOracleConn(String url) throws SQLException {
Connection conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
conn = DriverManager.getConnection(ORACLE + url, "scott", "tiger");
return conn;
}
}
Êý¾Ý¿âÁ´½ÓÀà——Í¨¹ýÅäÖÃÎļþ
/*
* Db.java
Created on 2007Äê8ÔÂ20ÈÕ, ÉÏÎç 8:37
*/
import
java.io.
*
;
import
java.sql.
*
;
import
java.util.Properties;
public
class
Db {
private
String driver;
private
String url;
private
String user;
private
String password;
private
Connection conn;
private
Statement stm;
private
ResultSet rs;
public
Db(){
this
(
"
DBConf.properties
"
);
}
Ïà¹ØÎĵµ£º
²»¹ÜÄãÐŲ»ÐÅ£¬¼´Ê¹¶àôÊìÁ·±à³ÌµÄÈËÔ±ÔÚcodingµÄʱºò¶¼»á³öÏÖÒâÏë²»µ½µÄbug¡£ÔÚÉÏƪÎÄÕÂÖÐÎÒÔøÌáµ½£¬bugµÄÔì³ÉÊǶà¸ö·½ÃæµÄ×ۺϽá¹û£¬ÓÐЩbugÊÇ¿ÉÒÔÐÞ¸´µÄ£¬µ«ÊÇÓÐЩÂß¼ÉϵÄbugÒªÐÞ¸´¿É²»ÊÇÄÇôÈÝÒ×µÄÊÂÇ飬¾ÍÏñÎÒÃÇ×ö´íÁËÒ»¼þÊÂÇ飬Èç¹û²»È¥´Ó¸ù±¾ÉϸÄÕý¾Í»á·¸¸ü´óµÄ´íÎóÒ»Ñù£¬ÓÐʱºòbugÒ²ÊÇÒ»¸ö»ýÀ ......
(1). ´´½¨Ò»¸ö½Ó¿Ú, Òª´úÀíµÄÀàºÍ ´úÀíÀ඼½«¼Ì³ÐËü
package stone;
public interface Image {
public void show();
}
(2). ´´½¨Òª±»´úÀíµÄÀà:
package stone;
public class BigImage implements Image {
public BigImage() {
......
Ò»¸ö¼òµ¥µÄË«»÷¾ÍÄÜÔËÐÐjarÎļþµÄ´ò°ü¹ý³Ì:
http://blog.csdn.net/ihc523/archive/2009/10/11/4636832.aspx
eclipseµ¼³öjarÎļþÔÙ½«Ëüת»»³Éexe¿ÉÖ´ÐÐÎļþ:
http://hi.baidu.com/%C4%CF%BA%BD%CC%EC%CF%C2/blog/item/1601a381ac9af9d1bd3e1e3d.html
´òJar°üµÄÒ»¸öEclipse²å¼þFatJar:
http://blog.csdn.net/lqsmn613/ar ......
±¾ÎÄÖ÷Ҫ̸һÏÂÃÜÂëѧÖеļÓÃܺÍÊý×ÖÇ©Ãû£¬ÒÔ¼°ÆäÔÚjavaÖÐÈçºÎ½øÐÐʹÓ᣶ÔÃÜÂëѧÓÐÐËȤµÄ»ï°é£¬ÍƼö¿´Bruce SchneierµÄÖø×÷£ºApplied Crypotography.ÔÚjdk1.5µÄ·¢Ðа汾Öа²È«ÐÔ·½ÃæÓÐÁ˺ܴóµÄ¸Ä½ø£¬Ò²ÌṩÁ˶ÔRSAËã·¨µÄÖ±½ÓÖ§³Ö£¬ÏÖÔÚÎÒÃÇ´ÓʵÀýÈëÊÖ½â¾öÎÊÌ⣨±¾ÎĽöÊÇ×÷Ϊ¼òµ¥½éÉÜ£©£º
Ò»¡¢ÃÜÂëѧÉÏ ......
1.×Ö·û
x ×Ö·û x¡£ÀýÈça±íʾ×Ö·ûa
\\ ·´Ð±Ïß×Ö·û¡£ÔÚÊéдʱҪдΪ\\\\¡££¨×¢Ò⣺ÒòΪjavaÔÚµÚÒ»´Î½âÎöʱ,°Ñ\\\\½âÎö³ÉÕýÔò±í´ïʽ\\£¬ÔÚµÚ¶þ´Î½âÎöʱÔÙ½âÎöΪ\£¬ËùÒÔ·²ÊDz»ÊÇ1.1Áоٵ½µÄתÒå×Ö·û£¬°üÀ¨1.1µÄ\\,¶øÓÖ´øÓÐ\µÄ¶¼ÒªÐ´Á½´Î£©
\0n ´øÓа˽øÖÆÖµ 0µÄ×Ö·û ......