Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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()


Ïà¹ØÎĵµ£º

java¸ñʽ»¯ÈÕÆÚʱ¼äµÄº¯Êý

Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyÄêMMÔÂddÈÕ HH:mm:ss");
System.out.println(sdf.format(date));
SimpleDateFormat sdf2 = new SimpleDateFormat("MM");
System.out.println(sdf2.format(date));
Calendar c = Calendar.getInstance();
System.out.println(c.get(C ......

javaÔðÈÎÁ´Ä£Ê½

ÔðÈÎÁ´Ä£Ê½
Ò»¡¢¶¨ÒåÓë½á¹¹
´ÓÃû×ÖÉÏ´ó¸ÅÒ²Äܲ³öÕâ¸öģʽµÄ´ó¸ÅÄ£Ñù——ϵͳÖн«»á´æÔÚ¶à¸öÓÐÀàËÆ´¦ÀíÄÜÁ¦µÄ¶ÔÏó¡£µ±Ò»¸öÇëÇó´¥·¢ºó£¬ÇëÇó½«ÔÚÕâЩ¶ÔÏó×é³ÉµÄÁ´ÌõÖд«µÝ£¬Ö±µ½ÕÒµ½×îºÏÊʵēÔðÈΔ¶ÔÏ󣬲¢½øÐд¦Àí¡£
¡¶Éè¼Æģʽ¡·ÖиøËüµÄ¶¨ÒåÈçÏ£ºÊ¹¶à¸ö¶ÔÏó¶¼Óлú»á´¦ÀíÇëÇ󣬴Ӷø±ÜÃâÇëÇóµÄ· ......

Java ¶íÂÞ˹·½¿é

import java.awt.*;
import java.awt.event.*;
//¶íÂÞ˹·½¿éÀà
public class ERS_Block extends Frame{
 public static boolean isPlay=false;
 public static int level=1,score=0;
 public static TextField scoreField,levelField;
 
 public static MyTimer timer;
 Ga ......

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

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

VCÐÞ¸ÄAccessÃÜÂë

void ModifyDBCode()
{
 CString strPath;
 ::GetModuleFileName(GetModuleHandle(NULL),strPath.GetBuffer(256),256);
 strPath.ReleaseBuffer();
 int flag=strPath.ReverseFind('\\');
 int size=strPath.GetLength();
 strPath.Delete(flag,size-flag);
 strPath= strPath+ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ