<!----><!----> <!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> <!---->
JDBC: ( MySqlCode )
01_Import Jar File
02_Load Driver
03_Statement Execute:
04_Output:ResultSet
04_close
1、加载及注册JDBC驱动程序
sd="com.mysql.jdbc.Driver"
sc="jdbc:mysql://localhost:3306/database"
2、建立连接对象
Class.forName(sd);
myconn=(Connection) DriverManager.getConnection(sc, "root", "root");
3、建立 SQL 陈述式对象( Statement Object )
Statement state=(Statement) myconn.createStatement();
4、执行 SQL 语句
查询:executeQuery()
String query = "select * from test";
ResultSet rs=state.executeQuery(query);
结果集 ResultSet
while (rs.next())
{rs.getString(1);
rs.getInt(1); }
更新:executeUpdate()
String upd="insert into test (id,name) values(1001,xuzhaori)";
int con=state.executeUpdate(upd);
execute()