zoukankan      html  css  js  c++  java
  • jsp连接mysql

    jsp连接数据库有几种,我选择的是jdbc连接,跨平台,但是需要提前下好相应的驱动(jar包),百度即可

    然后 1. 将jar包放在 tomcat/lib/文件夹下

      2.另一个包需要在工程下导入,我是myeclipse导入的,具体过程可百度

    以下是连接代码:

                //之前需要导入  import java.sql.*;
    Connection con=null; Statement stmt = null;
                //前面的基本不变,localhost 端口号 根据情况做改变 /mydatabase 是数据库的名字
             final String DBURL = "jdbc:mysql://localhost:3306/mydatabase"; 
           //用户名
    final String DBUSER = "root";
           //密码
    final String DBPWD = "123456"; try{ Class.forName("com.mysql.jdbc.Driver");// load the Connecting class con = DriverManager.getConnection(DBURL, DBUSER, DBPWD); }catch(Exception e){ out.print("连接失败!!<br>"+
    e.toString()); }
  • 相关阅读:
    python 网络爬虫(三)
    python 网络爬虫(二)
    python 网络爬虫(一)
    python 爬虫原理
    (转)栈的生长方向
    CRC校验
    extern关键字
    E
    The Super Powers UVA
    V
  • 原文地址:https://www.cnblogs.com/ax7399/p/4926366.html
Copyright © 2011-2022 走看看