基于jdbc+mysql的数据库连接

来源:互联网 发布:mac word 字数统计 编辑:程序博客网 时间:2024/05/16 05:12
<%
  final String DBDRIVER="org.gjt.mm.mysql.Driver";
  final String DBURL="jdbc:mysql://localhost/mldn";
  final String DBUSER="root";
  final String DBPASSWORD="123";
  Connection conn=null;
%>
<%
  try{
  Class.forName(DBDRIVER);
  conn=DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD);
  Statement stmt=conn.createStatement();
  String sql="insert yyp values('shz','xxy',234);";
  stmt.executeUpdate(sql);
  stmt.close();
  }
  catch(Exception e)
  {
   out.print(e);
  }
%>