JAVAµ÷ÓÃMYSQL´æ´¢¹ý³Ì
JAVAµ÷ÓÃMYSQL´æ´¢¹ý³Ì
¹¤³ÌÊÓͼ£º
´úÂëÇåµ¥£º
myconn.java
package org.apache.sh_mysql.test;
import java.sql.*;
public class MyConn {
private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String URL = "jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=GBK";
private static final String USER = "root";
private static final String PASSWORD ="root";
static {
try {
Class.forName(DRIVER);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* »ñÈ¡Á¬½Ó
*
* @return
* @throws Exception
*/
public Connection getConnection() throws Exception {
return DriverManager.getConnection(URL, USER, PASSWORD);
}
/**
* ÊÍ·Å×ÊÔ´
*
* @param rs
* @param statement
* @param conn
*/
public void close(ResultSet rs, CallableStatement stmt, Connection conn) {
try{
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
}catch(Exception e){
e.printStackTrace();
}
}
}
´úÂëÇåµ¥£º
mytest.java
package org.apache.sh_mysql.test;
import java.sql.*;
public class MyTest {
MyConn c=new MyConn();
public void handleData() {
try {
Connection conn=c.getConnection();
CallableStatement call=conn.prepareCall("{call pro_stu_count(?)}");
call.registerOutParameter(1, Types.INTEGER);
call.execute();
int count=call.getInt(1);
System.out.println(count);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public static void main(String[] args) {
MyTest t=new MyTest();
t.handleData();
}
}
Ïà¹ØÎĵµ£º
¾õµÃÁôÑÔºÜÓеÀÀí£¬ÎÄÕºÜÕÜÀí£¬Ò»²¢×ªÔØ ½¨Òé¶ÁÕß¿´ÔÎĵØÖ·
×÷Õߣº ÈîÒ»·å
ÈÕÆÚ£º 2008Äê12Ô 7ÈÕ
ÏÂÃæµÄÎÄÕÂÊÇMore Joel on SoftwareÒ»ÊéµÄµÚ8ƪ¡£
ÎÒ¾õµÃ·ÒëÄѶȺܴó£¬ÕûÕûÁ½¸ö¹¤×÷ÈÕ£¬Ã¿Ìì8СʱÒÔÉÏ£¬²ÅÒë³öÁË5000×Ö¡£³ýÁËJoel´óÁ¿Ê¹ÓÃÙµÓÁíÒ»¸öÔÒòÊÇÔÎÄÉæ¼°"±à³ÌÔÀí"£¬ºÃ¶à¶«Î÷ÎÒ¸ù±¾²»¶®¡£Ï£ ......
ÒÔÇ°¶¼ÊÇÓÃÒ»°ãµÄsocket±à³Ì£¬ÓÃÏß³ÌÀ´¿ØÖÆ¡£×î½üͻȻÓÃnioÀ´×öЩ¶«Î÷¡£
nioµÄºÃ´¦ÎÒÀ´ËµÒ»Ï£ºµÚÒ»£¬¶Áд¶¼ÊÇ»ùÓÚ¿éµÄ£¬Ð§Âʸߡ£µÚ¶þ£¬Í¨¹ýÒýÈëselector,¼ò»¯ÁËÍøÂç±à³ÌÄ£ÐÍ£¬Òì²½·Ç×èÈû¡£
¼ÈÈ»ÓÐÕâô¶àºÃ´¦£¬ÄǾÍд¸öNIO TCPÍøÂçÁÄÌìÊÒÀ´Á·Á·ÊÖ°É¡£
ÒòΪûÓÐдgui£¬ÊÇ»ùÓÚ¿ØÖÆ̨µÄËùÒÔûд˽Á˵IJ¿·Ö£¬Ö»Ð´Á˹«¹²ÁÄÌìÊ ......
public class MyEnumTestMain {
public enum MyenumTest{red,blue,green,black}//¶¨Òåö¾ÙÀàÐÍ
public static void main(String[] args) {
MyenumTest mt = MyenumTest.red;//redÏ൱ÓÚö¾ÙµÄ¾²Ì¬ÊôÐÔ
switch(mt){
case red:
System.out.println("red");
break;
case blue:
......
×Ô¼ºµÄÔ´³ÌÐòÊÇÔÚF:\parser\ParserDemo.java£¬
ʹÓÃÃüÁîÐУºjavac -classpath stanford-parser.jar;. ParserDemo.java±àÒ룬
ÃüÁîÐУºjava -cp stanford-parser.jar;. ParserÔËÐÐ
¶¼Ã»ÓÐÎÊÌâ¡£
µ«Êǵ±ÎÒÔÚc++³ÌÐòÖÐʹÓÃÓÃÃüÁîÐУ¨java -cp stanford-parser.jar;. Parser£©µ÷ÓøijÌÐò¾Í»á³ö´í¡£Ìáʾ£ºjava.lang.NoClassD ......
½ñÌì´ÓͬѧÃÇÄÇÀï¸ãÁËÁ½¸ö·Ç½Èí¼þ£¬Ò»¸öÊÇÎ޽磬һ¸öÊÇ×ÔÓÉÃÅ£¬¸ÕÌýµ½·Ç½Èí¼þ´ó¼ÒÒ»¶¨ºÜÃÔºý°É£¬ÎÒÒ²ÊǸÕÖªµÀÓÐÕâÖÖ¶«Î÷£¬Ìý˵ÓÃÕâÖÖÈí¼þ¿ÉÒÔ·ÃÎÊһЩ±»¹ú¼Ò½ûÖ¹·ÃÎʵÄÍøÕ¾£¬È·ÇеÄ˵¾ÍÊÇÒ»ÖÖ´úÀí»úÖÆ£¬´ó¼Ò²»Òª¶àÏ룬ÎÒŪÕâ¸ö¶«Î÷û±ðµÄÄ¿µÄ£¬¶¯»úÊǺܵ¥´¿µÄ£¬¾ÍÊÇÏë¿´Ò»¿´È«Çò×î´óµÄÊÓƵ ......