Class.forName("com.exasol.jdbc.EXADriver"); String url = "jdbc:exa:<hostname>:<port>;schema=<schema>;user=<user>;password=<password>"; Connection conn = DriverManager.getConnection(url); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM table_name"); while (rs.next()) { } PreparedStatement pstmt = conn.prepareStatement("INSERT INTO table_name (col1, col2) VALUES (?, ?)"); pstmt.setString(1, value1); pstmt.setInt(2, value2); pstmt.executeUpdate(); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); stmt.addBatch("INSERT INTO table_name (col1, col2) VALUES (val1, val2)"); stmt.addBatch("INSERT INTO table_name (col1, col2) VALUES (val3, val4)"); stmt.executeBatch(); conn.commit(); <resource-ref> <res-ref-name>jdbc/EXADatasource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> <bean id="dataSource" class="com.exasol.jdbc.EXAConnectionPoolDataSource"> <property name="user" value="username" /> <property name="password" value="password" /> <property name="url" value="jdbc:exa:<hostname>:<port>;schema=<schema>" /> </bean>


上一篇:
下一篇:
切换中文