Click here to Skip to main content
15,605,987 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day everyone, I have been watching this video series as a guide line for my own netbeans e commerce project but at 42:00 the teacher adds a DB Query Database but when I added this code to my index.jsp file I got this error message in my browser “jakarta.servlet.jsp.JspException: Unable to get connection, DataSource invalid: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: The connection property 'zeroDateTimeBehavior' only accepts values of the form: 'exception', 'round' or 'convertToNull'. The value 'CONVERT_TO_NULL' is not in this set." I have the jdbc/OkStore resource reference in web.xml. I changed the resource type to javax.sql.DataSource. I changed the datasource classname from com.mysql.jdbc.jdbc2.optional.MysqlDataSource to com.mysql.cj.jdbc.MysqlDataSource. Do you guys have any ideas to fix this? By the way I will be updating the post with failed solutions so that I don’t get repeats.

The program versions I’m using are Apache Netbeans IDE 15, MySQL WorkBench 8.0 CE, Eclipse GlassFish 6.2.5 (build 6.x-b66-g0159b68 2022-02-12T17:39:59+0000). My driver is mysql-connector-j-8.0.31.

Error message

DB Query Database code in index.jsp file that caused the error message
<sql:query var="categories" datasource="jdbc/OkStore">
SELECT * FROM category

The jdbc/OkStore resource reference code in web.xml file
<description>Connects to database for OkStore application

Here's the code for for index.jsp
[code=xml]<%@taglib prefix="c" uri=""%>
<%@taglib prefix="sql" uri=""%>
    Document   : index.jsp
    Created on : Dec 10, 2022, 2:51:39 PM
    Author     : Bredy
      <sql:query var="categories" dataSource="jdbc/OkStore">
        SELECT * FROM category
        <div id="indexLeftColumn">            
            <div id="welcomeText">
        <p>[ welcome text ]</p>
     <!-- test to access context parameters -->
        categoryImagePath: ${initParam.categoryImagePath}
        productImagePath: ${initParam.productImagePath}   
        <div id="indexRightColumn">           
          <div class="categoryBox">
        <a href="#">
            Under Armour
    <div class="categoryBox">
        <a href="#">
    <div class="categoryBox">
        <a href="#">
    <div class="categoryBox">
        <a href="#">
</div>  [/code]
Here's the code for for web.xml
[code=xml]<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns=""
    <description>The relative path to product images</description>
    <description>The relative path to category images</description>
    <description>header and footer settings</description>
    <description>Connects to database for OkStore application</description>

What I have tried:

List of failed solutions
I changed the datasource name from com.mysql.cj.jdbc.MysqlDataSource to com.mysql.cj.jdbc.Driver in the Glassfish Domain Admin Console and I got a new error. "Ping Connection Pool failed for OkStorePool. Class name is wrong or classpath is not set for : com.mysql.cj.jdbc.Driver." So I swap backed to com.mysql.cj.jdbc.MysqlDataSource.
The datasource name change error:
Updated 27-Dec-22 12:05pm
Richard MacCutchan 27-Dec-22 5:47am    
Instead of all those links to external websites, please use the Improve question link above, and add the actual code you are using.
Makito Bredy 27-Dec-22 17:15pm    
Alright I have added some code.
Gerry Schmitz 27-Dec-22 12:19pm    
Did your find the "CONVERT_TO_NULL" value it's complaining about? Sounds like a "constant name" and not a "value".
Makito Bredy 27-Dec-22 18:04pm    
THANK YOU! I figured out what I need to do.

1 solution

Guys I fixed the problem. I went to the glassfish-resources.xml file and changed the value jdbc:mysql://localhost:3306/okstore?zeroDateTimeBehavior=CONVERT_TO_NULL to jdbc:mysql://localhost:3306/okstore?zeroDateTimeBehavior=convertToNull. I also changed the database connection to jdbc:mysql://localhost:3306/okstore?zeroDateTimeBehavior=convertToNull just in case.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900