[英]Get DB2-specific parser instance
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. 我正在尝试创建一个简单的插件,可以在其中从日志中粘贴sql查询,并使其在表中显示列名和插入的值。 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'
. 除了日期和时间之外,我都可以使用它,因为我们的DB2数据库使用特殊值,例如
{d: '2014-07-03'}
而不是'2014-07-03'
。
How do I figure out what values I need to pass to SQLQueryParserManagerProvider.getInstance().getParserManager( dbProduct , dbVersion );
如何确定需要传递给
SQLQueryParserManagerProvider.getInstance().getParserManager( dbProduct , dbVersion );
to get the right parser that can handle these values? 获得可以处理这些值的正确解析器?
Set up a connection in the Database Development view (I called mine QA
), double click to open a connection, then run: 在“数据库开发”视图中建立一个连接(我称为mine
QA
),双击以打开一个连接,然后运行:
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
method was taken from the end of this page : 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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.