javaÓëÍøÂç
1 ÍøÂçͨÐŵı¾ÖÊÊǽø³Ì¼äͨÐÅ¡£
2 TcpÐÒéºÍUDPÐÒé
TCP£º¿ªÏú´ó£¬ÓÃÓÚ¿É¿¿ÐÔÒªÇó¸ßµÄ³¡ºÏ¡£
TCPµÄ¹ý³ÌÏ൱ÓÚ´òµç»°µÄ¹ý³Ì
UDP£ºÓÃÔÚ¶ÔʵʱÐÔÒªÇó±È½Ï¸ßµÄ³¡ºÏ¡£
UDPµÄ¹ý³ÌÏ൱ÓÚдÐŵĹý³Ì¡£
×¢Ò⣺socketÊÇÌ×½Ó×Ö£¬ipºÍport£¨¶Ë¿ÚºÅ 0~65535¸ö¶Ë¿Ú£¬Ò»¸ö¶Ë¿ÚÖ»ÄÜÓÐÒ»¸ö½ø³Ì£©
3£¬ TCPͨÐÅ»úÖÆ£¬tcpÊÇÃæÏòÁ¬½ÓµÄ£¬ÊµÏÖ¶àÏ̵߳ķ½·¨ÓÐÈý¸ö
¢Ù Ϊÿ¸ö¿Í»§·ÖÅäÒ»¸ö¹¤×÷Ï̡߳£
¢Ú ´´½¨Ò»¸öÏ̳߳أ¬ÓÉÆäÖеŤ×÷Ïß³ÌÀ´Îª¿Í»§·þÎñ¡£
¢Û ÀûÓÃJDKµÄJavaÀà¿âÖÐÏֳɵÄÏ̳߳أ¬ÓÉËüµÄ¹¤×÷Ïß³ÌÀ´Îª¿Í»§·þÎñ¡£
ÏÂÃæÒÔΪÿ¸ö¿Í»§·ÖÅäÒ»¸ö¹¤×÷Ïß³ÌÀ´ÊµÏÖ¶àÏß³Ì
ÔÚ·þÎñ¶Ë
import java.net.*;
import java.io.*;
public class TCPServer2 {
public static void main(String[] args) throws Exception{
ServerSocket ss=new ServerSocket(9000);//¶Ë¿ÚºÅ
while(true){
Socket s=ss.accept();//Á¬½Ó¼àÌý¿Í»§¶Ë
System.out.println(s.getInetAddress());
Thread t=new ServerThread(s);//ʵÏÖ¶àÏß³ÌÁ¬½Ó
t.start();
}
}
}
class ServerThread extends Thread{//·ÖÅäÏß³Ì
Socket s;
public ServerThread(Socket s){
this.s=s;
}
public void run(){
try {
OutputStream os=s.getOutputStream();//ÔÚÍøÂçÖлñÈ¡Êä³öÁ÷
PrintWriter out=new PrintWriter(os);
for(int i=1;i<=30;i++){
out.println("Hello "+i);//ͨ¹ýÍøÂç·¢ÏûÏ¢¸ø¿Í»§¶Ë
out.flush();
Thread.sleep(1000);
}
} catch (Exception
Ïà¹ØÎĵµ£º
µÚ8Õ ¶àÏß³Ì
(Ò»)¿Î³ÌÄÚÈÝ
8.1Ï̵߳Ļù±¾¸ÅÄî
8.1.1Ï̵߳ÄÉúÃüÖÜÆÚ
8.1.2Ï̵߳÷¶ÈÓëÓÅÏȼ¶
8.2 ThreadÀàºÍRunnable½Ó13
8.2.1 ThreadÀà
8.2.2 Runnable½Ó¿Ú
8.3Ï̻߳¥³âºÍͬ²½
8.3.1Ï̻߳¥³â
8.3.2Ïß³Ìͬ²½
(¶þ)ѧϰĿµÄÓëÒªÇó
±¾Õ½éÉܶàÏ̵߳ĸÅÄîºÍ±àд¶àÏ̳߳ÌÐòµÄ·½·¨£¬ÊµÏÖÏß³ÌÖ®¼äÏ໥ͨÐźÍͬ²½µÄ¼¼ ......
//´òÓ¡³ömess±íµÄÁÐÊýÊǶàÉÙ
public static void main(String[] args){
String sql="select count(*) from mess";
ResultSet set=null;
try {
Object paramValues[] = new Object[0];
set = DBUtil.preExec ......
1£®JavaµÄ¼òµ¥ÀàÐͼ°Æä·â×°Æ÷Àà
¢ÅJava¼òµ¥ÀàÐÍÓë·â×°Àà
ÎÒÃÇÖªµÀ,JavaÓïÑÔÊǵäÐ͵ÄÖ§³ÖÃæÏò¶ÔÏóµÄ³ÌÐòÓïÑÔ,µ«¿¼Âǵ½ÓÐЩ»ù±¾Êý¾ÝÀàÐ͵Ľṹ¼òµ¥,Õ¼ÄÚ´æÐ¡ÇÒ´æÈ¡ËÙ¶È¿ìµÈÓŵã,JavaÒÀÈ»ÌṩÁ˶ÔÕâЩ·ÇÃæÏò¶ÔÏóµÄ¼òµ¥Êý¾ÝÀàÐ͵ÄÖ§³Ö¡£µ±È»,JavaÔÚÌṩ´óÁ¿µÄÆäËüÀàʱ,Ò²ÌṩÁËÓë¼òµ¥Êý¾ÝÀàÐͶÔÓ¦µÄ·â×°Àà,ÓÚÊÇ,JavaÖ ......
´úÂëÈçÏ£º
1 String command = " cmd /c C:/Program Files/MySQL/MySQL Server 5.0/bin>mysqldump -h localhost -u root -p aijia > E:/aijia.dmp " ;
2 try {
3 Process process& ......
×î½üÓöµ½Ò»¸öÐèÇóÒªÔÚlinuxÏÂÓÃjava µ÷ÓÃmysql¿Í»§¶ËÔ¶³ÌµÇ½mysql·þÎñÆ÷£¬´Ó¿Í»§¶Ë»úÆ÷µ¼Èëmysql½Å±¾£¬´Ómysql·þÎñÆ÷¶Ëµ¼³ö±íÖеÄÊý¾Ý¡£ÒÔÏÂÊÇÓõ½µÄÖ÷Òª·½·¨£º
Java ´úÂë
/**
* µ¼ÈëÊý¾Ý
* @param ½Å±¾µÄµØÖ·ºÍÃû³Æ
* @return ÊÇ·ñ³ ......