Search code examples
netbeansglassfishmysql-workbenchnetbeans-8

Netbeans connection property only accepts values of the form: 'exception', 'round' or 'convertToNull' The value 'CONVERT_TO_NULL' is not in this set


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 and mysql-connector-java-5.1.47.

Good day everyone, before you tell me this is a duplicate question let me explain you how it’s different. I first got this error in Glassfish Domain Admin Console when I checked the JDBC Connection Pool’s ping. I fixed the error but now I’m getting the error in my browser when I run the project. 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. I have deleted the old driver and downloaded the new one. 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. https://www.youtube.com/watch?v=JlLGrqHSSjk&list=PLWS58wV27xi5AFrSfru26h4KWNMv1h2XA&index=16&ab_channel=CS.Math.Educator 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
    </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 Glassfish - No suitable driver for mysql when trying to connect with datasource

java.sql.SQLException: No suitable driver found for CONNECTION_URL

Class name is wrong or classpath is not set for : com.mysql.jdbc.Driver

javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found

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


Solution

  • Guys I fixed the problem. 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.