Using Hibernate to work with Text Files

后端 未结 3 801
执念已碎
执念已碎 2021-01-02 15:17

I am using Hibernate in a Java application to access my Database and it works pretty well with MS-SQL and MySQL. But some of the data I have to show on some forms has to com

相关标签:
3条回答
  • 2021-01-02 15:36

    Like erickson said, your only hope is in finding a JDBC driver for that task. There is maybe xlsql (CSV, XML and Excel driver) which could fit the task. After that, you just have to either find or write the most simple Hibernate Dialect which fits your driver.

    0 讨论(0)
  • 2021-01-02 15:40

    Hibernate is written against the JDBC API. So, you need a JDBC driver that works with the file format you are interested in. Obviously, even for read-only access, this isn't going to perform well, but it might still be useful if that's not a high priority. On a Windows system, you can set up ODBC datasources for delimited text files, Excel files, etc. Then you can set up the JdbcOdbcDriver in your Java application to use this data source.

    For most of the applications I work on, I would not consider this approach; I would use an import/export mechanism to convert from a real database (even if it's an in-process database like Berkeley DB or Derby) to the text files. Yes, it's an extra step, but it could be automated, and the performance isn't likely to be much worse than trying to use the text files directly (it will likely be much better, overall), and it will be more robust and easy to develop.

    0 讨论(0)
  • 2021-01-02 15:44

    A quick google came up with

    • JDBC driver for csv files
    • JDBC driver for XML files

    Hope this might provide some inspiration?

    0 讨论(0)
提交回复
热议问题