码迷,mamicode.com
首页 > 数据库 > 详细

数据库插入操作

时间:2017-07-09 12:30:27      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:span   val   create   static   stat   pre   man   str   void   

 1 package org.lxh.demo17.statementdemo;
 2 
 3 import java.sql.Connection;
 4 import java.sql.DriverManager;
 5 import java.sql.Statement;
 6 
 7 public class InsertDemo01 {
 8     private static final String DBDRIVER = "com.mysql.jdbc.Driver";
 9     private static final String DBURL = "jdbc:mysql://localhost:3306/mldn";
10     private static final String DBUSER = "root";
11     private static final String DBPASS = "root";
12     public static void main(String[] args) throws Exception {
13         Connection conn = null;
14         Statement stmt = null;
15         String sql = "insert into user(name,password,age,sex,birthday)"+
16                 "values(‘张三‘,‘www.mldn,cn‘,30,‘男‘,‘2008-08-27‘)";
17         Class.forName(DBDRIVER);
18         conn = DriverManager.getConnection(DBURL, DBUSER, DBPASS);
19         stmt = conn.createStatement();
20         stmt.executeUpdate(sql);
21         stmt.close();
22         conn.close();
23     }
24 
25 }

 

数据库插入操作

标签:span   val   create   static   stat   pre   man   str   void   

原文地址:http://www.cnblogs.com/XuGuobao/p/7140618.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!