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

The following examples show how to use com.github.davidmoten.rx.jdbc.Database. These examples are extracted from open source projects. 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 Project: tutorials   Source File: InsertClobIntegrationTest.java    License: 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 Project: tutorials   Source File: InsertBlobIntegrationTest.java    License: 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 Project: rxjava-jdbc   Source File: ColumnNotFoundTest.java    License: 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
@Bean
public Database db(DataSource ds){
    return Database.fromDataSource(ds);
}
 
Example 5
RxJavaPostRepository(Database db) {
    this.db = db;
}