Sebastian | 2016-02-01 07:57:34.0 | |
Hi there,
let's say I have two DBF files in the directory "c:/test". One is called "test_1.dbf", the other one is called "test~1.dbf". The connection string then would be: "jdbc:DBF:///c:/test" If I run this: Connection con = DriverManager.getConnection(url, "", ""); ResultSet rs = con.getMetaData().getColumns(null, null, "test_1", null); the ResultSet object does not only contain the column metadta from test_1.dbf, but from test~1.dbf, too! How can I stop this without changing the file name? Sebastian | ||
Sebastian | 2016-02-02 02:07:27.0 | |
Yeah, I'm an idiot. As it turns out, die table name parameter in the getColumns() method is used as a pattern and the underscore matches any character.
But there still is a problem. When I try to escape the underscore the getColumns() method will return an empty result set. My code: Class.forName("com.hxtt.sql.dbf.DBFDriver").newInstance(); String url = "jdbc:DBF:///c:/dbf"; Connection con = DriverManager.getConnection(url, "", ""); System.out.println(con.getMetaData().getSearchStringEscape()); ResultSet rs = con.getMetaData().getColumns(null, null, "test\\_1", null); while (rs.next()) { // 3 == table name // 4 == column name System.out.println(rs.getString(3) + " - " + rs.getString(4)); } What am I doing wrong? | ||
HXTT Support | 2016-02-04 03:21:51.0 | |
At http://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html ,
Within a pattern String, "%" means match any substring of 0 or more characters, and "_" means match any one character. Only metadata entries matching the search pattern are returned. But there is not an escape character defination for \:( We will add that feature soon. | ||
Sebastian | 2016-02-04 03:24:02.0 | |
I worked around this issue - thanks for the information, though!
| ||
HXTT Support | 2016-02-08 22:15:58.0 | |
The latest package has supported \ as escape character for metadata. | ||
Sebastian | 2016-02-09 01:16:37.0 | |
Thanks! |