首页 > 代码库 > 数据库插入操作
数据库插入操作
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 }
数据库插入操作
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。