com.github.davidmoten.rx.jdbc.Database Java Examples

The following examples show how to use com.github.davidmoten.rx.jdbc.Database. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InsertClobIntegrationTest.java    From tutorials with MIT License 6 votes vote down vote up
@Before
public void setup() throws IOException {
    create = db.update("CREATE TABLE IF NOT EXISTS SERVERLOG_TABLE (id int primary key, document CLOB)")
      .count();

    InputStream actualInputStream = new FileInputStream("src/test/resources/actual_clob");
    this.actualDocument = Utils.getStringFromInputStream(actualInputStream);

    InputStream expectedInputStream = new FileInputStream("src/test/resources/expected_clob");
    this.expectedDocument = Utils.getStringFromInputStream(expectedInputStream);
    this.insert = db.update("insert into SERVERLOG_TABLE(id,document) values(?,?)")
      .parameter(1)
      .parameter(Database.toSentinelIfNull(actualDocument))
      .dependsOn(create)
      .count();
}
 
Example #2
Source File: InsertBlobIntegrationTest.java    From tutorials with MIT License 6 votes vote down vote up
@Before
public void setup() throws IOException {
    create = db.update("CREATE TABLE IF NOT EXISTS SERVERLOG (id int primary key, document BLOB)")
      .count();

    InputStream actualInputStream = new FileInputStream("src/test/resources/actual_clob");
    this.actualDocument = Utils.getStringFromInputStream(actualInputStream);
    byte[] bytes = this.actualDocument.getBytes(StandardCharsets.UTF_8);

    InputStream expectedInputStream = new FileInputStream("src/test/resources/expected_clob");
    this.expectedDocument = Utils.getStringFromInputStream(expectedInputStream);
    this.insert = db.update("insert into SERVERLOG(id,document) values(?,?)")
      .parameter(1)
      .parameter(Database.toSentinelIfNull(bytes))
      .dependsOn(create)
      .count();
}
 
Example #3
Source File: ColumnNotFoundTest.java    From rxjava-jdbc with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
    TestSubscriber<Object> ts = new TestSubscriber<Object>();
    Database db = DatabaseCreator.db();
    db.select("select name from Person").autoMap(Thing.class).count().subscribe(ts);
    ts.assertError(SQLRuntimeException.class);
    assertTrue(ts.getOnErrorEvents().get(0).getMessage()
            .startsWith("query column names do not include 'bingo'"));
}
 
Example #4
Source File: DataSourceConfig.java    From spring-reactive-sample with GNU General Public License v3.0 4 votes vote down vote up
@Bean
public Database db(DataSource ds){
    return Database.fromDataSource(ds);
}
 
Example #5
Source File: RxJavaPostRepository.java    From spring-reactive-sample with GNU General Public License v3.0 4 votes vote down vote up
RxJavaPostRepository(Database db) {
    this.db = db;
}