Jdbc
Contents of the JDBC Utils package
Performing a driver load in a static code block
Class.forName ("Com.mysql.jdbc.Driver");
Four private variables, which need to be modified when the database is different;
Private static final String username = "root";
Private static final String password = "root";
Private static final String URL = "Jdbc:mysql://localhost/mysql?seunicode=true&characterencoding=utf8";
private static final String drivername = "Com.mysql.jdbc.Driver";
Then encapsulated the ExecuteQuery (Connection conn,string sql,object...parameters)/executequery (sql,parameters)
Executeupdate (Connection conn,string sql,object...parameters)/executeupdate (sql,parameters)
and the corresponding close (conn/rs) method;
SQL additions and deletions change clause
SELECT * FROM table name
Select name from table name where conditional statement Name=value
Insert into table name (property name 1, property name 2 ...) values (attribute value 1, property value 2 ...);
Update table Name set Name=value, name2=value2 ... where condition statement;
Delete from table where Name=value
The total MySQL database Query method can be select COUNT (*) from table (table name); Total: Select count as TotalCount from table1 summation: select sum (field1) As Sumvalue from table1 average: Select AVG (field1) as Avgvalue from table1 maximum: select Max (field1) as MaxValue from table1 min: Select Min (field1) as MinValue from table1
Http://www.cnblogs.com/cunkouzh/p/5588319.html
JDBC Common Memos