myeclipse与mysql连接运行servlet出问题

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "3306:myceshi"
myceshi是数据库名

java.lang.NumberFormatException: For input string: "3306:myceshi"
这个异常是由于他准备把你的"3306:myceshi"这个值转换为数字,所有是这里出错了
你这个其实是你的数据库连接写法错了改成这样
3306/myceshi
如果不行的话,把你的数据库连接代码或配置文件发到我邮箱:rabbit110423@163.com

你把你的连接代码贴出来

我把它发过去了,请多指教。

/**

  • 链接mysql数据库
  • @author weichk
    */
    public class JDBC {
    private static final String URL = "jdbc:mysql://localhost:3306/myceshi";
    private static final String USER = "root";
    private static final String PASSWORD = "root";

    static {
    try {
    Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e) {
    System.out.println("加载Mysql数据库驱动失败!");
    }
    }

    /**

    • 获取Connection
    • @return
    • @throws SQLException
    • @throws ClassNotFoundException */ public static Connection getConnection() throws SQLException { Connection conn = null; try { conn = DriverManager.getConnection(URL, USER, PASSWORD); } catch (SQLException e) { System.out.println("获取数据库连接失败!"); throw e; } return conn; }

    /**

    • 关闭ResultSet
    • @param rs */ public static void closeResultSet(ResultSet rs) { if (rs != null) { try { rs.close(); } catch (SQLException e) { System.out.println(e.getMessage()); } } }

你的驱动包有了吗?密码正确?

多谢各位问题已经解决