如何修复Java中未找到tzdb.dat的错误? [英] How to fix tzdb.dat not found error in java?

查看:326
本文介绍了如何修复Java中未找到tzdb.dat的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将gradle项目与sqlite数据库连接时,出现错误:

When I try to connect my gradle project with sqlite database, I have an error:

Exception in thread "main" java.lang.Error: 

    java.io.FileNotFoundException: null\lib\tzdb.dat (The system cannot find the path specified)
        at sun.util.calendar.ZoneInfoFile$1.run(ZoneInfoFile.java:261)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.util.calendar.ZoneInfoFile.<clinit>(ZoneInfoFile.java:251)
        at sun.util.calendar.ZoneInfo.getTimeZone(ZoneInfo.java:589)
        at java.util.TimeZone.getTimeZone(TimeZone.java:560)
        at java.util.TimeZone.setDefaultZone(TimeZone.java:666)
        at java.util.TimeZone.getDefaultRef(TimeZone.java:636)
        at java.util.TimeZone.getDefault(TimeZone.java:625)
        at org.sqlite.date.FormatCache.getInstance(FormatCache.java:74)
        at org.sqlite.date.FastDateFormat.getInstance(FastDateFormat.java:129)
        at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:70)
        at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:25)
        at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:24)
        at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
        at org.sqlite.JDBC.createConnection(JDBC.java:114)
        at org.sqlite.JDBC.connect(JDBC.java:88)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:270)
        at repository.JdbcUtils.getNewConnection(JdbcUtils.java:39)
        at repository.JdbcUtils.getConnection(JdbcUtils.java:52)
        at repository.RepositoryLog.findOne(RepositoryLog.java:28)
        at Main.main(Main.java:28)
    Caused by: java.io.FileNotFoundException: null\lib\tzdb.dat (The system cannot find the path specified)
        at java.io.FileInputStream.open0(Native Method)
        at java.io.FileInputStream.open(FileInputStream.java:195)
        at java.io.FileInputStream.<init>(FileInputStream.java:138)
        at sun.util.calendar.ZoneInfoFile$1.run(ZoneInfoFile.java:255)
        ... 21 more

我已经尝试调试它,但是它说这是一个时区问题,我不知道为什么会出现此问题.我以为这可能是Java10的问题,所以我也安装了Java1.8,但没有用.

I've tried to debug it but it says that it is a timezone problem and I don't know why this issue appears. I thought that this could be a a problem because of Java10, so I also installed Java1.8 but it didn't work.

        private Connection getNewConnection()
           {

    //I use the driver and the url from a bd.config file and it is saved in my //variables corectly

               String driver= jdbcProps.getProperty("jdbc.driver");
               String url=jdbcProps.getProperty("jdbc.url");
               String user=jdbcProps.getProperty("jdbc.user");
               String pass=jdbcProps.getProperty("jdbc.pass");


               Connection con=null;
               try{
                   Class.forName(driver);
             //this is where my error appears
                   con= DriverManager.getConnection(url);
               } catch (ClassNotFoundException e) {
                   e.printStackTrace();
               } catch (SQLException e) {
                   System.out.println("Error getting connection "+e);
                //e.printStackTrace();
               }
               return con;
           }

我希望只连接到我的数据库并与数据库牢固地合作

I expect only to connect to my database and work with the database corectly

推荐答案

转到您的 C:\ Program Files \ Java \ jre1.8.0_202 \ lib 目录,搜索tzdb.dat文件并复制从这里将其粘贴到 C:\ Program Files \ Java \ jdk-13 \ lib 目录中希望它能工作

Go to your C:\Program Files\Java\jre1.8.0_202\lib directory search for tzdb.dat file and copy it from here and paste in C:\Program Files\Java\jdk-13\lib directory hope it will work

这篇关于如何修复Java中未找到tzdb.dat的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆