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
|
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?
|
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.
|
I worked around this issue - thanks for the information, though!
|
|
The latest package has supported \ as escape character for metadata.
|