Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : java

JAVAÁ¬½ÓÊý¾Ý¿â´óÈ«

JAVAÁ¬½ÓÊý¾Ý¿â´óÈ«
 
 
1£®Oracle8/8i/9iÊý¾Ý¿â£¨thinģʽ£©
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:ts"; //tsΪÊý¾Ý¿âµÄSID
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
2£®DB2Êý¾Ý¿â
Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
String url="jdbc:db2://localhost:5000/stu"; //stuΪÄãµÄÊý¾Ý¿âÃû
String user="admin";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
3£®Sql Server7.0/2000Êý¾Ý¿â
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";
//mydbΪÊý¾Ý¿â
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
4£®SybaseÊý¾Ý¿â
Class.forName("com.sybase.jdbc.SybDriver").newInstance();
String url =" jdbc:sybase:Tds:localhost:5 ......

²ÉÓÃJavaµÄÀà½øÐÐmd5¼ÓÃÜ

´úÂëÈçÏ£º
package com.test.j2se;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5 {
/**Êý¾Ý¼ÓÃÜ
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
MessageDigest code = MessageDigest.getInstance("MD5");
String str = "ADFSE";
System.out.println("before md5:"+str);
code.update(str.getBytes());
byte[] bs = code.digest();
StringBuffer sb = new StringBuffer();
for(int i =0;i<bs.length;i++) {
// System.out.println("bs["+i+"]="+bs[i]);
int v = bs[i]& 0xff;
if(v <16) {
sb.append(0);
}
sb.append(Integer.toHexString(v).toUpperCase());
}
System.out.println("length ="+sb.length());
System.out.println("after md5 :"+sb.toString());
System.out.println("5tohexStrin="+Integer.toHexString(17));
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} ......

JAVA NIO TCP SOCKET ÁÄÌìȺ·¢

ÒÔÇ°¶¼ÊÇÓÃÒ»°ãµÄsocket±à³Ì£¬ÓÃÏß³ÌÀ´¿ØÖÆ¡£×î½üͻȻÓÃnioÀ´×öЩ¶«Î÷¡£
nioµÄºÃ´¦ÎÒÀ´ËµÒ»Ï£ºµÚÒ»£¬¶Áд¶¼ÊÇ»ùÓÚ¿éµÄ£¬Ð§Âʸߡ£µÚ¶þ£¬Í¨¹ýÒýÈëselector,¼ò»¯ÁËÍøÂç±à³ÌÄ£ÐÍ£¬Òì²½·Ç×èÈû¡£
¼ÈÈ»ÓÐÕâô¶àºÃ´¦£¬ÄǾÍд¸öNIO TCPÍøÂçÁÄÌìÊÒÀ´Á·Á·ÊÖ°É¡£
ÒòΪûÓÐдgui£¬ÊÇ»ùÓÚ¿ØÖÆ̨µÄËùÒÔûд˽Á˵IJ¿·Ö£¬Ö»Ð´Á˹«¹²ÁÄÌìÊÒ¡££¨Æäʵ£¬¼ÈÈ»ÊÇ·þÎñÆ÷¶Ë¿ÉÒÔ·Ö·¢¸øËùÓÐÈË£¬·Ö·¢¸øÌض¨ÈËÒ²ÊǺÜÈÝÒ×ʵÏֵġ£
×¢Ò⣺ÕâÀïÖ»ÊÇΪÁËÁ·ÊÖ£¬ÁªÏµ·þÎñÆ÷¶Ë·Ö·¢ÏûÏ¢µ½¸÷¸ö¿Í»§¶Ë¡£TCP À´Ð´ÁÄÌìÊÒ£¬ÔÚÏÖʵÖÐÊDz»¿ÉÈ¡µÄ¡£IM¶¼ÊÇ»ùÓÚUDPÀ´Ð´µÄ¡£
ÏÈÉÏ´úÂë°É¡£
·þÎñÆ÷¶Ë´úÂë MySocketServer.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kevin.nio;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Date;
import java.util.Iterator;
import ......

JavaÖеÄö¾ÙÀàÐÍ£¬enum

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:
System.out.println("blue");
break;
default:
System.out.println("ÆäËû");
}
}
}
......

java JDBC ResultSetÏê½â(javaÊý¾Ý¿â²Ù×÷)

ÕâƪÎÄÕ²¢Ã»Óиø³öÈçºÎʹÓÃResultSetµÄ¾ßÌåÀý×Ó£¬Ö»ÊÇ´ÓResultSetµÄ¹¦ÄÜÐÔÉϽøÐÐÁËÏêϸµÄ½²Êö¡£Ï£ÍûÕâƪÎÄÕ¶Դó¼ÒÀí½âResultSetÄܹ»ÓÐËù°ïÖú¡£ÏÂÃæ¾ÍÊÇÕâƪÎÄÕµľßÌåÄÚÈÝ¡£
½á¹û¼¯(ResultSet)ÊÇÊý¾ÝÖвéѯ½á¹û·µ»ØµÄÒ»ÖÖ¶ÔÏ󣬿ÉÒÔ˵½á¹û¼¯ÊÇÒ»¸ö´æ´¢²éѯ½á¹ûµÄ¶ÔÏ󣬵«Êǽá¹û¼¯²¢²»½ö½ö¾ßÓд洢µÄ¹¦ÄÜ£¬Ëûͬʱ»¹¾ßÓвÙ×ÝÊý¾ÝµÄ¹¦ÄÜ£¬¿ÉÄÜÍê³É¶ÔÊý¾ÝµÄ¸üеȡ£
½á¹û¼¯¶ÁÈ¡Êý¾ÝµÄ·½·¨Ö÷ÒªÊÇgetXXX()£¬ËûµÄ²ÎÊý¿ÉÒÔʹÕûÐͱíʾµÚ¼¸ÁУ¨ÊÇ´Ó1¿ªÊ¼µÄ£©£¬»¹¿ÉÒÔÊÇÁÐÃû¡£·µ»ØµÄÊǶÔÓ¦µÄXXXÀàÐ͵ÄÖµ¡£Èç¹û¶ÔÓ¦ÄÇÁÐʱ¿ÕÖµ£¬XXXÊǶÔÏóµÄ»°·µ»ØXXXÐ͵ĿÕÖµ£¬Èç¹ûXXXÊÇÊý×ÖÀàÐÍ£¬ÈçFloatµÈÔò·µ»Ø0£¬boolean·µ»Øfalse¡£Ê¹ÓÃgetString()¿ÉÒÔ·µ»ØËùÓеÄÁеÄÖµ£¬²»¹ý·µ»ØµÄ¶¼ÊÇ×Ö·û´®ÀàÐ͵ġ£XXX¿ÉÒÔ´ú±íµÄÀàÐÍÓУº»ù±¾µÄÊý¾ÝÀàÐÍÈçÕûÐÍ(int)£¬²¼¶ûÐÍ(Boolean)£¬¸¡µãÐÍ(Float,Double)µÈ£¬±ÈÌØÐÍ£¨byte£©£¬»¹°üÀ¨Ò»Ð©ÌØÊâµÄÀàÐÍ£¬È磺ÈÕÆÚÀàÐÍ£¨java.sql.Date£©£¬Ê±¼äÀàÐÍ(java.sql.Time)£¬Ê±¼ä´ÁÀàÐÍ(java.sql.Timestamp)£¬´óÊýÐÍ(BigDecimalºÍBigIntegerµÈ)µÈ¡£»¹¿ÉÒÔʹÓÃgetArray(int colindex/String columnname)£¬Í¨¹ýÕâ¸ö·½·¨»ñµÃµ±Ç°ÐÐÖУ¬colindexËùÔÚÁеÄÔªËØ×é³ÉµÄ¶ÔÏóµÄÊý×é¡ ......

ÓÃJavaʵÏÖ·Ç×èÈûͨÐÅ

ÓÃServerSocketºÍSocketÀ´±àд·þÎñÆ÷³ÌÐòºÍ¿Í»§³ÌÐò£¬ÊÇJavaÍøÂç±à³ÌµÄ×î»ù±¾µÄ·½Ê½¡£ÕâЩ·þÎñÆ÷³ÌÐò»ò¿Í»§³ÌÐòÔÚÔËÐйý³ÌÖг£³£»á×èÈû¡£ÀýÈçµ±Ò»¸öÏß³ÌÖ´ÐÐServerSocketµÄaccept()·½·¨Ê±£¬¼ÙÈçûÓпͻ§Á¬½Ó£¬¸ÃÏ߳̾ͻáÒ»Ö±µÈµ½ÓÐÁË¿Í»§Á¬½Ó²Å´Óaccept()·½·¨·µ»Ø¡£ÔÙÀýÈçµ±Ïß³ÌÖ´ÐÐSocketµÄread()·½·¨Ê±£¬Èç¹ûÊäÈëÁ÷ÖÐûÓÐÊý¾Ý£¬¸ÃÏ߳̾ͻáÒ»Ö±µÈµ½¶ÁÈëÁË×ã¹»µÄÊý¾Ý²Å´Óread()·½·¨·µ»Ø¡£
¼ÙÈç·þÎñÆ÷³ÌÐòÐèҪͬʱÓë¶à¸ö¿Í»§Í¨ÐÅ£¬¾Í±ØÐë·ÖÅä¶à¸ö¹¤×÷Ị̈߳¬ÈÃËüÃÇ·Ö±ð¸ºÔðÓëÒ»¸ö¿Í»§Í¨ÐÅ£¬µ±È»Ã¿¸ö¹¤×÷Ï̶߳¼ÓпÉÄܾ­³£´¦ÓÚ³¤Ê±¼äµÄ×èÈû״̬¡£
´ÓJDK1.4°æ±¾¿ªÊ¼£¬ÒýÈëÁË·Ç×èÈûµÄͨÐÅ»úÖÆ¡£·þÎñÆ÷³ÌÐò½ÓÊÕ¿Í»§Á¬½Ó¡¢¿Í»§³ÌÐò½¨Á¢Óë·þÎñÆ÷µÄÁ¬½Ó£¬ÒÔ¼°·þÎñÆ÷³ÌÐòºÍ¿Í»§³ÌÐòÊÕ·¢Êý¾ÝµÄ²Ù×÷¶¼¿ÉÒÔ°´·Ç×èÈûµÄ·½Ê½½øÐС£·þÎñÆ÷³ÌÐòÖ»ÐèÒª´´½¨Ò»¸öỊ̈߳¬¾ÍÄÜÍê³ÉͬʱÓë¶à¸ö¿Í»§Í¨ÐŵÄÈÎÎñ¡£
·Ç×èÈûµÄͨÐÅ»úÖÆÖ÷ÒªÓÉjava.nio°ü£¨ÐÂI/O°ü£©ÖеÄÀàʵÏÖ£¬Ö÷ÒªµÄÀà°üÀ¨ServerSocketChannel¡¢SocketChannel¡¢Selector¡¢SelectionKeyºÍByteBufferµÈ¡£
Ò»¡¢Ïß³Ì×èÈû
ÔÚÉú»îÖУ¬×î³£¼ûµÄ×èÈûÏÖÏóÊǹ«Â·ÉÏÆû³µµÄ¶ÂÈû¡£Æû³µÔÚ¹«Â·ÉÏ¿ìËÙÔËÐУ¬Èç¹ûÇ°·½½»Í¨ÊÜ×裬¾ÍÖ»ºÃÍ£ÏÂÀ´µÈ´ý£¬µÈµ½¹«Â·Ë ......
×ܼǼÊý:6386; ×ÜÒ³Êý:1065; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [14] [15] [16] [17] 18 [19] [20] [21] [22] [23]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ