Java·ÖÒ³£¨Ö§³Ö¶àÖÖÊý¾Ý¿â£©
×î½üÑо¿ÁËÏ·ÖÒ³£¬×ö¸ö×ܽᡣ
1£©Êý¾Ý¿â²Ù×÷Àà,×ö¼òµ¥·â×° DB.java
package Test;
import java.sql.*;
public class DB {
// ¼ÓÔØÇý¶¯
static {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Çý¶¯¼ÓÔسö´í");
}
}
// »ñÈ¡Êý¾Ý¿âÁ¬½Ó
public static Connection getConn() {
Connection conn = null;
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost/userinfo?user=root&password=abcd");
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
// ¹Ø±ÕÊý¾Ý¿âÁ¬½Ó
public static void closeConn(Connection conn) {
try {
if(conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
// ¹Ø±ÕStatement
public static void closeStmt(Statement stmt) {
try {
if(stmt != null) {
stmt.close();
stmt = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
// ¹Ø±ÕResultSet
public static void closeRs(ResultSet rs) {
try {
if(rs != null) {
rs.close();
rs = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
****************************
Ïà¹ØÎĵµ£º
һЩjavaÀàÖÐΪʲôÐèÒªÖØÔØ serialVersionUID ÊôÐÔ¡£
ÔÚJavaÖУ¬Èí¼þµÄ¼æÈÝÐÔÊÇÒ»¸ö´óÎÊÌ⣬ÓÈÆäÔÚʹÓõ½¶ÔÏó´®ÐÐÐÔµÄʱºò£¬ÄÇôÔÚijһ¸ö¶ÔÏóÒѾ±»´®Ðл¯ÁË£¬¿ÉÊÇÕâ¸ö¶ÔÏóÓÖ±»Ð޸ĺóÖØв¿ÊðÁË£¬ÄÇôÔÚÕâÖÖÇé¿öÏ£¬ ÓÃÀÏÈí¼þÀ´¶ÁÈ¡ÐÂÎļþ¸ñʽËäÈ»²»ÊÇʲôÄÑÊ£¬µ«ÊÇÓпÉÄܶªÊ§Ò»Ð©ÐÅÏ¢¡£
serialVersionUID À´½â¾öÕâЩΠ......
java»ñÈ¡µ±Ç°Â·¾¶[ת]
¹Ø¼ü×Ö: java ·¾¶
java »ñÈ¡µ±Ç°Â·¾¶
1 ¡¢ÀûÓà System.getProperty() º¯Êý»ñÈ¡µ±Ç°Â·¾¶£º
System.out.println(System.getProperty("user.dir"));//user.dir Ö¸¶¨Á˵±Ç°µÄ·¾¶
2 ¡¢Ê¹Óà File ÌṩµÄº¯Êý»ñÈ¡µ±Ç°Â·¾¶£º
File directory = new File("");// É趨Ϊµ±Ç°Îļþ ......
//³õѧJAVA ¿ª·¢ÁËÒ»¸ö ѧÉú¹ÜÀí³ÌÐò£¬ÄóöÀ´É¹É¹£¬ÒÔ±ã´ó¼Ò²Î¿¼»òÆÀÂÛ Ö¸³ö²»×ãÖ®´¦£¡Ð»Ð» ÓÉÓÚ´Ë´¦²»ÄÜÉÏ´«ÕÕƬ£¬¹Ê·ÅÔÚÎÒµÄÏà
//²áÀïÃæ
//Õâ¸öµÇÈë½çÃæµÄ³ÌÐò£º
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
impor ......
¡¾Ö÷Ìâ¡¿ Java»ù±¾Êý¾ÝÀàÐ͵ÄÔËËã
¡¾¹Ø¼ü×Ö¡¿java »ù±¾Êý¾ÝÀàÐÍ
¡¾ÎÊÌâÃèÊö¡¿Çë¿´Èç¹ûÒ»¶Î´úÂë,Èç¹û²»ÔÚeclipseÀïÔËÐÐ,Çëд³öÊä³ö½á¹û
public static void main(String[] args) {
&n ......
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.font.TextAttribute;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import java.text.AttributedCharacterIterator;
import java.text. ......