jdbcÁ¬½ÓmysqlÎÊÌâ
Java code:
import java.sql.*;
public class DBTester1 {
public static void main(String[] args) throws Exception {
Connection con;
Statement stmt;
ResultSet rs;
Class.forName("com.mysql.jdbc.Driver");
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
String dbUrl =
"jdbc:mysql://localhost:3306/STOREDB?useUnicode=true&characterEncoding=GB2312";
String dbUser = "dbuser";
String dbPwd ="1234";
con = java.sql.DriverManager.getConnection(dbUrl,dbUser,dbPwd);
stmt= con.createStatement();
stmt.executeUpdate("insert into CUSTOMERS (NAME,AGE,ADDRESS)"
+"VALUES('СÍõ',20,'ÉϺ£')");
rs = stmt.executeQuery("SELECT ID,NAME,AGE,ADDRESS from CUSTOEMRS");
while(rs.next())
{
long id = rs.getLong(1);
String name = rs.getString(2);
int age = rs.getInt(3);
String address = rs.getString(4);
System.out.println("id="+id+",name="+name+",age="+age+",address="+address);
}
stmt.executeUpdate("delete from CUSTOMERS where name='СÍõ'");
rs.close();
stmt.close();
con.close();
Ïà¹ØÎÊ´ð£º
ÎÒÓÃÒ»¸öÑ»·ÍùÊý¾Ý¿âÀïÃæ´æÎļþ£¬±¾À´¿ÉÒÔ×÷ΪÎļþ´æ·ÅÊý¾Ý¿âÀïÃæÖ»·ÅÎļþµÄλÖõģ¬µ«ÊÇûÓа취×âµÄ·þÎñÆ÷ÍøÒ³¿Õ¼ä´óСÓÐÏÞÖÆÊý¾Ý¿âûÓÐÏÞÖÆ¡£Óï¾äÊÇÕâÑùµÄ
public static final DataBase.MAXSIZE=102 ......
MySqlÖвåÈ뵱ǰʱ¼äµÄ¸ÃÔõôд°¡£¿
now()
SQL code:
sqlÀïÊÇ£º
getdate()
ÒýÓÃ
now()
ѧϰ
SQL code:
select now();
SQL code:
TODAY()
?
SQL code:
select now();
/* ......
±í½á¹¹
mysqlÊý¾Ý
ÍøÒ³ÏÔʾµÄÊý¾Ý
ÏÖÔÚÎÊÌâ¾ÍÊÇ£¬³ýÁËÖ÷¼üÓÐÖµÍ⣬ÆäËü×Ö¶ÎÈ«²¿Îª¿Õ¡£
ÕâÀïºÍÈÕÎÄÓйØϵ£¬Ï£ÍûÓÐÄÜÓÐÄãµÄ°ïÖú¡£Ð»Ð»
ÓÐʱºòһˢеÄʱºò£¬»¹³öÏÖÕâÖÖÎ ......
<form action="" method="post" onSubmit="return aa();" >
<body onload="setup()">
<div align="center" class="STYLE1"&g ......
mysql ÖÐÒ»¸ö±íÖÐ×Ö¶ÎÈçÏÂ: id value create_time Èý¸ö×Ö¶Î
ÈçÊý¾ÝÓÐ:
1 test1 2009-9-10
1 test2 2009-9-11
2 testg 2009-9-10
3 t ......