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.
Error message
https://i.stack.imgur.com/LgYcw.png
DB Query Database code in index.jsp file that caused the error message
<sql:query var="categories" dataSource="jdbc/OkStore">
SELECT * FROM category
</sql:query>
The jdbc/OkStore resource reference code in web.xml
<resource-ref>
<description>Connects to database for OkStore application</description>
<res-ref-name>jdbc/OkStore</res-ref-name>
<res-type>javax.sql.ConnectionPoolDataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
List of failed solutions
https://stackoverflow.com/questions/17378840/glassfish-no-suitable-driver-for-mysql-when-trying-to-connect-with-datasource
https://stackoverflow.com/questions/30871627/java-sql-sqlexception-no-suitable-driver-found-for-connection-url
https://stackoverflow.com/questions/23845408/class-name-is-wrong-or-classpath-is-not-set-for-com-mysql-jdbc-driver/52957026#52957026
https://stackoverflow.com/questions/20405273/javax-servlet-jsp-jspexception-unable-to-get-connection-datasource-invalid-j
https://stackoverflow.com/questions/22696902/jdbc-converting-timestamp-to-null-zerodatetimebehavior-issue
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:
https://i.stack.imgur.com/vAdD7.png