java.lang.NullPointerException:无法调用“java.sql.Connection.createStatement()”,因为“connection”为空

时间:2021-05-10 14:08:43

标签: java mysql jsp jdbc

<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>

<%

Connection connection=null;
    try{
            Class.forName("com.mysql.jdbc.Driver");
            connection= DriverManager.getConnection("jdbc:mysql://localhost:3306/social_network","root","Apsa@123");
        }
        catch(Exception e)
        {
            System.out.println(e);
        }       

%>

我收到以下异常

<块引用>

java.lang.NullPointerException:无法调用 “java.sql.Connection.createStatement()”因为“connection”为空

0 个答案:

没有答案