zoukankan      html  css  js  c++  java
  • jsp连接mysqladd操作

    编辑器加载中...<%@ page language="java" contentType="text/html; charset=gb2312" pageEncoding="gb2312" import="java.sql.*"%> insert数据
    <% String url = "jdbc:mysql://localhost:3306/test"; String user = "root"; String password = "110"; Connection conn = null; PreparedStatement pstmt = null; String driverName = "com.mysql.jdbc.Driver"; try { Class.forName(driverName).newInstance(); conn = DriverManager.getConnection(url, user, password); } catch (ClassNotFoundException e) { out.println(e); } catch (SQLException e) { out.println("连接SQLserver数据库失败!!!!!!"); } try { Statement stmt = conn.createStatement(); String sql = "insert into employee(id,name,age,address,city) values(2,'小名',20,'binghai','binghai road')"; stmt.executeUpdate(sql); } catch (SQLException e) { out.println("insert失败!"); } try { if (pstmt != null) { pstmt.close(); pstmt = null; } if (conn != null) { conn.close(); conn = null; } } catch (Exception e) { out.println("数据库关闭异常!"); } out.println("insert成功!"); %>
  • 相关阅读:
    代码示例_触摸屏驱动
    代码示例_中断下半部
    代码示例_mmap的实现
    代码示例_阻塞IO
    代码示例_LCD控制
    代码示例_平台总线
    驱动_I2c驱动框架
    驱动_Input输入子系统
    Windows切换桌面或窗口快捷键
    几何分布
  • 原文地址:https://www.cnblogs.com/atwanli/p/2772224.html
Copyright © 2011-2022 走看看