获取特定于DB2的解析器实例 [英] Get DB2-specific parser instance
问题描述
我正在尝试创建一个简单的插件,可以在其中从我们的日志中粘贴一个sql查询,并使其在表中显示列名和插入的值.除了日期和时间,我已经可以使用它了,因为我们的DB2数据库使用特殊的值,例如 {d:'2014-07-03'}
而不是'2014-07-03'
.
I'm trying to create a simple plugin where I can paste in an sql query from our logs and have it display the column names and inserted values in a table. I've got it working, except for dates and times, because our DB2 database uses special values like {d: '2014-07-03'}
rather than '2014-07-03'
.
如何确定需要传递给 SQLQueryParserManagerProvider.getInstance().getParserManager( dbProduct , dbVersion );
How do I figure out what values I need to pass to SQLQueryParserManagerProvider.getInstance().getParserManager(dbProduct,
dbVersion);
获得可以处理这些值的正确解析器?
to get the right parser that can handle these values?
推荐答案
在数据库开发"视图中建立连接(我叫我 QA
),双击打开连接,然后运行:
Set up a connection in the Database Development view (I called mine QA
), double click to open a connection, then run:
IConnectionProfile profile = ProfileManager.getInstance().getProfileByName("QA");
Database db = getDatabase(profile);
if (db != null) {
System.out.println("DB Vendor: " + db.getVendor());
System.out.println("DB Version: " + db.getVersion());
}
getDatabase
方法摘自此页面的结尾:>
private Database getDatabase(IConnectionProfile profile) {
IManagedConnection managedConnection = ((IConnectionProfile) profile)
.getManagedConnection("org.eclipse.datatools.connectivity.sqm.core.connection.ConnectionInfo");
if (managedConnection != null) {
try {
ConnectionInfo connectionInfo = (ConnectionInfo) managedConnection.getConnection().getRawConnection();
if (connectionInfo != null) {
Database database = connectionInfo.getSharedDatabase();
return database;
}
}
catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
这篇关于获取特定于DB2的解析器实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!