Can anybody please mention the best available opensource odbc:jdbc driver to read / write dbf.? I have a dbf file which I would like to query (select/update) via a web application (Tomcat app).
Any help/tips would be appreciative.
Thank you.
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String connString="jdbc:odbc:Driver={Microsoft dBASE Driver (*.dbf)};DefaultDir=E:\\db";//DeafultDir indicates the location of the db
Connection connection=DriverManager.getConnection(connString);
String sql="SELECT * FROM table_name where condition";// usual sql query
Statement stmt=connection.createStatement();
ResultSet resultSet=stmt.executeQuery(sql);
while(resultSet.next())
{
System.out.println();
}
System.out.println();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
catch (SQLException e)
{
e.printStackTrace();
}
It works. And I guess there will be no need to explore for other (open/closed) apis as Java has provided an excellent way to read/write dbf.
Thank you all.
You can try to use https://github.com/iryndin/jdbf - a simple Java library to read/write DBF files. I am the author of this library and it works quite good in my production apps. It is very simple.
Please give it a try.
dans-dbf is a good option to access dbf files, but it has a custom api (ie: not sql).
I would recommend you to dump the dbf files into db tables (mysql with myisam engine will do the trick or innodb if transaction/consistency checking is required).
Then you can dump back to dbf as needed.
来源:https://stackoverflow.com/questions/8064937/what-is-the-best-opensource-dbf-driver-for-java