How to save a dbf file in groovy or java?

雨燕双飞 提交于 2021-01-07 05:06:49

问题


In one of the questions regarding DBF creation, I found the code below. Did I understand correctly that a DBF file is created here with the names of the columns and the values that will be returned as a result of executing the SQL query? Does println do DBF output? And if everything is so, then how to save the resulting DBF file (name.dbf)?

I'm confused and can't figure it out with DBF. I need to create a DBF file and fill it with values by accessing a function in a SQL package. The second thing is clear to me, I can do it using sql.call and work with ResutSet, but how to save DBF to the computer further is not clear to me.

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();
        }

来源:https://stackoverflow.com/questions/65097720/how-to-save-a-dbf-file-in-groovy-or-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!