简体   繁体   English

java netbeans新的驱动程序类是`com.mysql.cj.jdbc.Driver'。

[英]java netbeans The new driver class is `com.mysql.cj.jdbc.Driver'

I keep on getting this error, can anybody tell me why this error occurs or how can i resolve it, its pretty much sure that its the database connection error, after i did some search, i Found the that they changed the mysql-connector class name: com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver, but Im still using the old connector so why do i keep getting this error. 我不断收到这个错误,有人可以告诉我为什么会发生这个错误,或者我该如何解决,我几乎确定是数据库连接错误,经过一些搜索后,我发现他们改变了mysql-connector类名称:com.mysql.jdbc.Driver到com.mysql.cj.jdbc.Driver,但是我仍在使用旧的连接器,所以为什么我不断收到此错误。

 run:
[EL Info]: 2019-03-03 09:55:13.058--ServerSession(11708955)--EclipseLink, version: Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
[EL Severe]: ejb: 2019-03-03 09:55:13.445--ServerSession(11708955)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: The connection property 'zeroDateTimeBehavior' acceptable values are: 'CONVERT_TO_NULL', 'EXCEPTION' or 'ROUND'. The value 'convertToNull' is not acceptable.
Error Code: 0
Internal Exception: java.sql.SQLException: The connection property 'zeroDateTimeBehavior' acceptable values are: 'CONVERT_TO_NULL', 'EXCEPTION' or 'ROUND'. The value 'convertToNull' is not acceptable.
Error Code: 0
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:766)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:304)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:336)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:302)
    at jayshree.steels.demo.Item_Details.initComponents(Item_Details.java:47)
    at jayshree.steels.demo.Item_Details.<init>(Item_Details.java:34)
    at jayshree.steels.demo.Item_Details$1.run(Item_Details.java:331)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: The connection property 'zeroDateTimeBehavior' acceptable values are: 'CONVERT_TO_NULL', 'EXCEPTION' or 'ROUND'. The value 'convertToNull' is not acceptable.
Error Code: 0
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:331)
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:326)
    at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)
    at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.setOrDetectDatasource(DatabaseSessionImpl.java:204)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:741)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:239)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:685)
    ... 21 more
Caused by: java.sql.SQLException: The connection property 'zeroDateTimeBehavior' acceptable values are: 'CONVERT_TO_NULL', 'EXCEPTION' or 'ROUND'. The value 'convertToNull' is not acceptable.
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:127)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:87)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:61)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:71)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:85)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:440)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:208)
    at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
    ... 26 more
Caused by: com.mysql.cj.exceptions.WrongArgumentException: The connection property 'zeroDateTimeBehavior' acceptable values are: 'CONVERT_TO_NULL', 'EXCEPTION' or 'ROUND'. The value 'convertToNull' is not acceptable.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:103)
    at com.mysql.cj.conf.DefaultPropertySet.initializeProperties(DefaultPropertySet.java:194)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:382)
    ... 31 more
Caused by: com.mysql.cj.exceptions.CJException: The connection property 'zeroDateTimeBehavior' acceptable values are: 'CONVERT_TO_NULL', 'EXCEPTION' or 'ROUND'. The value 'convertToNull' is not acceptable.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:103)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:149)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:122)
    at com.mysql.cj.conf.EnumPropertyDefinition.parseObject(EnumPropertyDefinition.java:64)
    at com.mysql.cj.conf.EnumPropertyDefinition.parseObject(EnumPropertyDefinition.java:39)
    at com.mysql.cj.conf.AbstractRuntimeProperty.setFromString(AbstractRuntimeProperty.java:96)
    at com.mysql.cj.conf.AbstractRuntimeProperty.initializeFrom(AbstractRuntimeProperty.java:91)
    at com.mysql.cj.conf.AbstractRuntimeProperty.initializeFrom(AbstractRuntimeProperty.java:75)
    at com.mysql.cj.conf.DefaultPropertySet.initializeProperties(DefaultPropertySet.java:191)
    ... 32 more
Caused by: java.lang.IllegalArgumentException: No enum constant com.mysql.cj.conf.PropertyDefinitions.ZeroDatetimeBehavior.CONVERTTONULL
    at java.lang.Enum.valueOf(Enum.java:238)
    at com.mysql.cj.conf.EnumPropertyDefinition.parseObject(EnumPropertyDefinition.java:62)
    ... 37 more
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true

I tried changing my url of database from convertToNull to CONVERT_TO_NULL but the same error occurs. 我尝试将数据库的URL从convertToNull更改为CONVERT_TO_NULL但是发生相同的错误。 Here is my connection code & im just displaying the contents of database in my form with the help of jTable in Netbeans 这是我的连接代码,我只是借助Netbeans中的jTable在表单中显示数据库的内容

public class MysqlConnection {
    public Connection con;
    /*public ResultSet rs;
    public Statement st;
    public PreparedStatement ps;
    public DataSource ds=null;*/
    public String User;
    public String Uid;
    public String Pwd;

    public String StrUrl="jdbc:mysql://localhost:50781/jayshreesteels?zeroDateTimeBehavior=CONVERT_TO_NULL";
    public String StrUid="root";
    public String StrPwd= "root";
    public static String StrUser;

    public static void main(String[] args) throws ClassNotFoundException, SQLException{
        String Url="jdbc:mysql://localhost:50781/jayshreesteels?zeroDateTimeBehavior=CONVERT_TO_NULL";
        Class.forName("com.mysql.cj.jdbc.Driver");
    }

    public MysqlConnection() throws SQLException {
        this.con = DriverManager.getConnection(StrUrl, "root", "root");
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 配置错误。 找不到 Class [com.mysql.cj.jdbc.Driver]。 EclipseLink, MySQL 驱动程序 - Configuration error. Class [com.mysql.cj.jdbc.Driver] not found. EclipseLink, MySQL driver centos8安装azkaban加载class`com.mysql.jdbc.Driver'。 这已被弃用。 新的驱动程序 class 是`com.mysql.cj.jdbc.Driver' - centos8 install azkaban Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver' Caused by: java.lang.RuntimeException: Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl - Caused by: java.lang.RuntimeException: Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl 无法从 HikariConfig 加载驱动程序 class com.mysql.cj.jdbc.Driver - Failed to load driver class com.mysql.cj.jdbc.Driver from HikariConfig 独立的 jpackage 生成 java 应用程序为 com.mysql.cj.Z84BZFFD.5A0D4966AD1C50DA4BEC50Z.mysql.cj.Z84BZFFD.5A0D4967C7ACEr708Driver7A7086 - Stand alone jpackage generated java app generates ClassNotFoundException for com.mysql.cj.jdbc.Driver 应用程序无法加载请求的 class:com.mysql.cj.Z84BEFFD3A0D49636A58CE6080CAADriver.8 - Application could not load requested class : com.mysql.cj.jdbc.Driver 如何为Liferay查找&#39;java.lang.ClassNotFoundException:com.mysql.cj.jdbc.Driver&#39; - How to fiw 'java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver' for liferay 在应用程序中,我具有对JDBC驱动程序的访问权限(java.lang.ClassNotFoundException除外:com.mysql.cj.jdbc.Driver) - In application I have acsess to JDBC driver (exception java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver) 无法加载驱动程序 class com.mysql.cj.jdbc.Driver 在 HikariConfig class 加载器或线程上下文类加载器中 - Failed to load driver class com.mysql.cj.jdbc.Driver in either of HikariConfig class loader or Thread context classloader Liquibase Windows MySQL - Cannot find database driver: com.mysql.cj.jdbc.Driver - Liquibase Windows MySQL - Cannot find database driver: com.mysql.cj.jdbc.Driver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM