Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java access sql

JDBCÁ¬½ÓMySQL
¼ÓÔؼ°×¢²áJDBCÇý¶¯³ÌÐò
Class.forName("com.mysql.jdbc.Driver");
Class.forName("com.mysql.jdbc.Driver").newInstance();
JDBC URL ¶¨ÒåÇý¶¯³ÌÐòÓëÊý¾ÝÔ´Ö®¼äµÄÁ¬½Ó
±ê×¼Óï·¨£º
<protocol£¨Ö÷ҪͨѶЭÒ飩>:<subprotocol£¨´ÎҪͨѶЭÒ飬¼´Çý¶¯³ÌÐòÃû³Æ£©>:<data source identifier£¨Êý¾ÝÔ´£©>
MySQLµÄJDBC URL¸ñʽ£º
jdbc:mysql//[hostname][:port]/[dbname][?param1=value1][&param2=value2]….

ʾÀý£ºjdbc:mysql://localhost:3306/sample_db?user=root&password=your_password

³£¼û²ÎÊý£º
user ̞
password ÃÜÂë
autoReconnect Áª»úʧ°Ü£¬ÊÇ·ñÖØÐÂÁª»ú£¨true/false£©
maxReconnect ³¢ÊÔÖØÐÂÁª»ú´ÎÊý
initialTimeout ³¢ÊÔÖØÐÂÁª»ú¼ä¸ô
maxRows ´«»Ø×î´óÐÐÊý
useUnicode ÊÇ·ñʹÓÃUnicode×ÖÌå±àÂ루true/false£©
characterEncoding ºÎÖÖ±àÂ루GB2312/UTF-8/…£©
relaxAutocommit ÊÇ·ñ×Ô¶¯Ìá½»£¨true/false£©
capitalizeTypeNames Êý¾Ý¶¨ÒåµÄÃû³ÆÒÔ´óд±íʾ
½¨Á¢Á¬½Ó¶ÔÏó
String url="jdbc:mysql://localhost:3306/sample_db?user=root&password=your_password";
Connection con = DriverManager.getConnection(url);
½¨Á¢SQL³ÂÊöʽ¶ÔÏó£¨Statement Object£©
Statement stmt = con.createStatement()£»
Ö´ÐÐSQLÓï¾ä
executeQuery()
String query = "select * from test";
ResultSet rs=stmt.executeQuery(query);
½á¹û¼¯ResultSet
while(rs.next())
{rs.getString(1);rs.getInt(2);}
executeUpdate()
String upd="insert into test (id,name) values(1001,xuzhaori)";
int con=stmt.executeUpdate(upd);
execute()


Ïà¹ØÎĵµ£º

ÓÃJAX WSʵÏÖjavaµ÷ÓÃwebServic

À´¸ö¼òµ¥µãµÄ£º
1.½¨¸ö¾ßÌåµÄ·þÎñʵÏÖ£º
package com.webservice;
@WebService
public class Warehouse {
 private Map<String, Double> prices;
 public Warehouse() {
  prices = new HashMap<String, Double>();
  prices.put("Blackwell Toaster", 24.95);
 & ......

¹ØÓÚjavaµÄ++ºÍ

public class JavaPlus {

public static void main(String[] args) {
int x = 5;
x++;// x = x + 1;//ºó¼Ó¼Ó
System.out.println(x);
x--;// x = x - 1;//ºó¼õ¼õ
System.out.println(x);
++x;// x = x + 1;//Ç°¼Ó¼Ó
Sys ......

javaÅÅÐòËã·¨»ã×Ü

Õâ¶Îʱ¼äÕýÔÚÕÒ¹¤×÷£¬Ñо¿ÁËÒ»ÏÂËã·¨¡£ÎÒÊÇ×öweb¿ª·¢µÄ£¬µ«ÊDZȽÏϲ»¶Ëã·¨µÄ£¬ËùÒÔ¾Í×ܽáÁËһϣ¬¾õµÃÈÔÓкܶ಻×㣬Çë´ó¼Ò¶à¶àÖ¸½Ì¡£Èç¹ûÓкÏÊʵŤ×÷ҲͦÍƼöÍƼöµÄ¡£ÎÒ×ö¿ª·¢ÒѾ­ÈýÄêÁË¡£ÎÒµÄÓÊÏ䣺zlljsf@gmail.com 
ÅÅÐòËã·¨³¬Àࣺ
/**
* ÅÅÐòËã·¨³¬Àà
* ËùÓÐÅÅÐòÐòÁÐÖÐÔªËرØÐëʵÏÖjava.lang.Comparable½Ó ......

Java·´Éä»úÖÆÉîÈëÑо¿

           
Java ·´ÉäÊÇJavaÓïÑÔµÄÒ»¸öºÜÖØÒªµÄÌØÕ÷£¬ËüʹµÃJava¾ßÌåÁË“¶¯Ì¬ÐÔ”¡£
 
ÔÚJavaÔËÐÐʱ»·¾³ÖУ¬¶ÔÓÚÈÎÒâÒ»¸öÀ࣬ÄÜ·ñÖªµÀÕâ¸öÀàÓÐÄÄЩÊôÐԺͷ½·¨£¿¶ÔÓÚÈÎÒâÒ»¸ö¶ÔÏó£¬ÄÜ·ñµ÷ÓÃËüµÄÈÎÒâÒ»¸ö·½·¨£¿´ð°¸Êǿ϶¨µÄ¡£ÕâÖÖ¶¯Ì¬»ñÈ¡ÀàµÄÐÅ ......

×·MMÓëJavaµÄ23ÖÖÉè¼Æģʽ

'   ¡¡1¡¢FACTORY—×·MMÉÙ²»ÁËÇë³Ô·¹ÁË£¬Âóµ±À͵ļ¦³áºÍ¿ÏµÂ»ùµÄ¼¦³á¶¼ÊÇMM°®³ÔµÄ¶«Î÷£¬ËäÈ»¿ÚζÓÐËù²»Í¬£¬µ«²»¹ÜÄã´øMMÈ¥Âóµ±ÀÍ»ò¿ÏµÂ»ù£¬Ö»¹ÜÏò·þÎñԱ˵“À´Ëĸö¼¦³á”¾ÍÐÐÁË¡£Âóµ±ÀͺͿϵ»ù¾ÍÊÇÉú²ú¼¦³áµÄFactory
¡¡¡¡¹¤³§Ä£Ê½£º¿Í»§ÀàºÍ¹¤³§Àà·Ö¿ª¡£Ïû·ÑÕßÈκÎʱºòÐèҪijÖÖ²úÆ·£¬Ö»ÐèÏò¹¤³ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ