Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何解决javaee项目中的时区错误?_Mysql_Jsp_Jdbc_Timezone - Fatal编程技术网

Mysql 如何解决javaee项目中的时区错误?

Mysql 如何解决javaee项目中的时区错误?,mysql,jsp,jdbc,timezone,Mysql,Jsp,Jdbc,Timezone,我知道这个问题不是第一次讨论,但是他们没有帮助我,请帮助我(最好是详细讨论)。 我在intellij IDEA上创建了一个EE web项目。 已连接MySQL(下图) 然后我用 index.jsp <% try { Class.forName("com.mysql.jdbc.Driver"); //load driver Connection con=DriverManager.getConnection("jdbc:mysql://l

我知道这个问题不是第一次讨论,但是他们没有帮助我,请帮助我(最好是详细讨论)。 我在intellij IDEA上创建了一个EE web项目。 已连接MySQL(下图) 然后我用 index.jsp

    <%
try
{
    Class.forName("com.mysql.jdbc.Driver"); //load driver
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/dbuser","root","root"); //create connection
    
    if(request.getParameter("btn_login")!=null) //check login button click event not null
    {
        String dbemail,dbpassword;
        
        String email,password;
        
        email=request.getParameter("txt_email"); //txt_email
        password=request.getParameter("txt_password"); //txt_password
        
        PreparedStatement pstmt=null; //create statement
        
        pstmt=con.prepareStatement("select * from login where email=? AND password=?"); //sql select query 
        pstmt.setString(1,email);
        pstmt.setString(2,password);
        
        ResultSet rs=pstmt.executeQuery(); //execute query and store in resultset object rs.
        
        if(rs.next())
        {
            dbemail=rs.getString("email");
            dbpassword=rs.getString("password");
            
            if(email.equals(dbemail) && password.equals(dbpassword))
            {
                session.setAttribute("login",dbemail); //session name is login and store fetchable database email address
                response.sendRedirect("welcome.jsp"); //after login success redirect to welcome.jsp page
            }
        }
        else
        {
            request.setAttribute("errorMsg","invalid email or password"); //invalid error message for email or password wrong
        }
        
        con.close(); //close connection 
    }
    
}
catch(Exception e)
{
    out.println(e);
}
%>
必须重写到

Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/dbuser?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC","root","root"); //create connection

必须重写到

Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/dbuser?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC","root","root"); //create connection

您好,检查答案可能会有帮助。@Swati我看了一下,但我到底要如何添加到代码中?您能否帮助更改您的连接字符串,如
“jdbc:mysql://localhost:3306/dbuser?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC“
然后看看这是否有效。。另外,该链接还有许多建议,请尝试其他链接,以及查看。@Swati但在这一行中,我们还必须将passwort写入本地服务器,所以我应该在哪里写入?“jdbc:mysql://localhost:3306/dbuser?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC"只需更改
jdbc:mysql://localhost:3306/dbuser
jdbc:mysql://localhost:3306/dbuser?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
在传递连接字符串的代码中。此外,密码和用户名将是相同的,无需在此处进行任何更改。您好,检查答案可能会有所帮助。@Swati我看了一下,但我如何确切地添加到我的代码中?您能否帮助更改您的连接字符串,如
“jdbc:mysql://localhost:3306/dbuser?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC“
然后看看这是否有效。。另外,该链接还有许多建议,请尝试其他链接,以及查看。@Swati但在这一行中,我们还必须将passwort写入本地服务器,所以我应该在哪里写入?“jdbc:mysql://localhost:3306/dbuser?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC"只需更改
jdbc:mysql://localhost:3306/dbuser
jdbc:mysql://localhost:3306/dbuser?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
在传递连接字符串的代码中。此外,密码和用户名将是相同的,无需进行任何更改。
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/dbuser?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC","root","root"); //create connection