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.
[youtube] https://www.youtube.com/watch?v=JlLGrqHSSjk&list=PLWS58wV27xi5AFrSfru26h4KWNMv1h2XA&index=16&ab_channel=CS.Math.Educator [/youtube]
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 drivers are mysql-connector-j-8.0.31.
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
<description>Connects to database for OkStore application</description>
The issue is in the configuration of your data source. So far you've shown us how you use the data source (index.jsp) and how you reference it (web.xml), but you haven't shown us how you've configured it. This is likely done in domain.xml of your GlassFish installation.
THANK YOU SO MUCH! I was stuck on this problem for days. I went to the glassfish-resources.xml file and changed 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.
Always look on the bright side of life. At least this ad is really tiny:
a bit of art, as a gift, that will fit in a stocking