简体   繁体   English

获取特定于DB2的解析器实例

[英]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.

相关问题 使用stax解析器从xml中仅获取特定元素节点 - Get only specific element node from xml using stax parser 使用 ZQL 或类似的 SQL 解析器获取特定列的表名,用于 java - Get the table name of a specific column with ZQL or similar SQL parser for java 如何在XML Pull Parser中获取特定的节点值 - How to get a specific node value in XML Pull Parser 如何从所属类的实例变量之一中获取类的特定实例 - How to get the specific instance of a class from one of the instance variables that belong to it 具有特定值解析器的PropertySourcesPlaceholderConfigurer - PropertySourcesPlaceholderConfigurer With Specific Value Parser 如何从Java中的另一个类获取类的特定实例? - How to get specific instance of class from another class in Java? 从MS Access 2016数据库获取特定月份的数据 - Get data for specific month from MS Access 2016 db 如何从Android中自己的SQL DB获取特定项目 - How to get specific item from own SQL DB in android 如何从JavaFX2的父控制器获取控制器的特定实例? - How to get specific instance of controller from parent controller at JavaFX2? 使用反射从扩展实例中获取特定属性 - Using reflection to get a specific attribute from a extended instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM