• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java OracleStatement类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中oracle.jdbc.OracleStatement的典型用法代码示例。如果您正苦于以下问题:Java OracleStatement类的具体用法?Java OracleStatement怎么用?Java OracleStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

OracleStatement类属于oracle.jdbc包,在下文中一共展示了OracleStatement类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: registerNotification

点赞 3

import oracle.jdbc.OracleStatement; //导入依赖的package包/类
public void registerNotification() throws SQLException{
    DatabaseChangeRegistration databaseChangeRegistration =  getOracleConnection().getConnection().registerDatabaseChangeNotification(properties);
    databaseChangeRegistration.addListener(new NsiListner(getQueueName()));
    Statement stm = getOracleConnection().getConnection().createStatement();
    ((OracleStatement) stm).setDatabaseChangeRegistration(databaseChangeRegistration);
    ResultSet rs;
    for(String queryString : getQueryString().split(";")){
        rs = stm.executeQuery(queryString);
        while(rs.next()){
        }
        rs.close();
    }
    // get tables from dcr
    String[] tables = databaseChangeRegistration.getTables();
    for(String str : tables){
        LOGGER.info("Registreted Tables:{}", str);
    }
    if(!stm.isClosed()){
        stm.close();
    }
}
 

开发者ID:srecon,
项目名称:OracleToElasticSearch,
代码行数:22,
代码来源:DBNotifactionConsumer.java

示例2: wrapStatement

点赞 2

import oracle.jdbc.OracleStatement; //导入依赖的package包/类
@Override
protected WrappedStatement wrapStatement(Statement s, String ref) {
	if (s instanceof OracleStatement) {
		return new WrappedOracleStatement(s, ref,
				getTransactionIdentifier(), this);
	}
	return super.wrapStatement(s, ref);
}
 

开发者ID:dd00f,
项目名称:ibm-performance-monitor,
代码行数:9,
代码来源:WrappedOracleConnection.java

示例3: startNotificationListener

点赞 2

import oracle.jdbc.OracleStatement; //导入依赖的package包/类
@Override
public void startNotificationListener(DBMSSynchronizer dbmsSynchronizer) {

    this.listener = new OracleNotificationListener(dbmsSynchronizer);

    try {
        oracleConnection = (OracleConnection) connection;

        Properties properties = new Properties();
        properties.setProperty(OracleConnection.DCN_NOTIFY_ROWIDS, "true");
        properties.setProperty(OracleConnection.DCN_QUERY_CHANGE_NOTIFICATION, "true");

        databaseChangeRegistration = oracleConnection.registerDatabaseChangeNotification(properties);
        databaseChangeRegistration.addListener(listener);

        try (Statement statement = oracleConnection.createStatement()) {
            ((OracleStatement) statement).setDatabaseChangeRegistration(databaseChangeRegistration);
            StringBuilder selectQuery = new StringBuilder()
                    .append("SELECT 1 FROM ")
                    .append(escape("ENTRY"))
                    .append(", ")
                    .append(escape("METADATA"));
            // this execution registers all tables mentioned in selectQuery
            statement.executeQuery(selectQuery.toString());
        }

    } catch (SQLException e) {
        LOGGER.error("SQL Error: ", e);
    }

}
 

开发者ID:JabRef,
项目名称:jabref,
代码行数:32,
代码来源:OracleProcessor.java

示例4: WrappedOracleStatement

点赞 2

import oracle.jdbc.OracleStatement; //导入依赖的package包/类
public WrappedOracleStatement(Statement statement, String ref,
		String transaction, Connection connection) {
	super(statement, ref, transaction, connection);
	oraclePs = (OracleStatement) statement;
}
 

开发者ID:dd00f,
项目名称:ibm-performance-monitor,
代码行数:6,
代码来源:WrappedOracleStatement.java

示例5: run

点赞 2

import oracle.jdbc.OracleStatement; //导入依赖的package包/类
private void run() throws Exception {
    System.out.println("Event Consumer Start...");
    OracleConnection connection = getConnection();
    Properties properties = new Properties();
    properties.setProperty(OracleConnection.DCN_NOTIFY_ROWIDS, "true");
    properties.setProperty(OracleConnection.DCN_QUERY_CHANGE_NOTIFICATION, "true"); //Activates query change notification instead of object change notification.

    // Register notifier
    DatabaseChangeRegistration reg = connection.registerDatabaseChangeNotification(properties);

    reg.addListener(new DatabaseChangeListener() {
        @Override
        public void onDatabaseChangeNotification(DatabaseChangeEvent databaseChangeEvent) {
            //TableChangeDescription tcd =  databaseChangeEvent.getTableChangeDescription()[0];
            QueryChangeDescription qcd =  databaseChangeEvent.getQueryChangeDescription()[0];
            TableChangeDescription tcd = qcd.getTableChangeDescription()[0];
            for(RowChangeDescription rcd : tcd.getRowChangeDescription()){
                System.out.println("Updated Row ID:" + rcd.getRowid().stringValue() + " Operation:" + rcd.getRowOperation().name());
                //System.out.printf("Full event: " + databaseChangeEvent);
            /*// emit rowid to Kafka cluster
                ProducerRecord<String,String> record = new ProducerRecord<String,String>(Producer.KAFKA_TOPIC, rcd.getRowid().stringValue(), rcd.getRowid().stringValue());

                Producer.getKafkaProducer().send(record, new Callback() {
                    @Override
                    public void onCompletion(RecordMetadata recordMetadata, Exception e) {
                        if(e != null){
                            e.printStackTrace();
                        } else{
                            System.out.printf("Message sent!");
                        }
                    }
                });*/
            }
        }
    });

    String query = "select * from temp t where t.a = 'a1'";
    Statement stm = connection.createStatement();
    ((OracleStatement) stm).setDatabaseChangeRegistration(reg);

    ResultSet rs = stm.executeQuery(query);
    //stm.executeQuery("select 1 from fdc_vt where 1!=2");
    //stm.executeQuery("select 1 from fdc_pt where 1!=2");
    while(rs.next()){
    }
    // get tables from dcr
    String[] tables = reg.getTables();
    for(String str : tables){
        System.out.println("Tables:"+ str);
    }
    rs.close();
    stm.close();
}
 

开发者ID:srecon,
项目名称:OracleToElasticSearch,
代码行数:54,
代码来源:DbEventConsumer.java

示例6: setLobPrefetchCount

点赞 2

import oracle.jdbc.OracleStatement; //导入依赖的package包/类
public void setLobPrefetchCount( Statement statement, Integer size ) throws SQLException {
    ( (OracleStatement) unwrapProxy(statement) ).setLobPrefetchSize( size );
}
 

开发者ID:NyBatis,
项目名称:NyBatisCore,
代码行数:4,
代码来源:OracleStatementController.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)