• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Netbeans “The value 'CONVERT_TO_NULL' is not in this set”

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Error-message.png
[Thumbnail for Error-message.png]
 
Bartender
Posts: 15737
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

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.
 
Mark Browne
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the code for for index.jsp

           
     
Here's the code for for web.xml

 
Stephan van Hulst
Bartender
Posts: 15737
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please reread my previous post carefully.
 
Mark Browne
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know how to check the configuration of the data source since I don't see the domain.xml.
 
Marshal
Posts: 4694
587
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Browne wrote:It looks like in that tutorial it is named glassfish-resources.xml

 
Mark Browne
Greenhorn
Posts: 10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
I think I'll just lie down here for a second. And ponder this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic