Github user HeartSaVioR commented on a diff in the pull request:
https://github.com/apache/storm/pull/458#discussion_r26190228
--- Diff: external/storm-jdbc/README.md ---
@@ -38,34 +63,30 @@ hikariConfigMap.put("dataSource.password","password");
String tableName = "user_details";
JdbcMapper simpleJdbcMapper = new SimpleJdbcMapper(tableName, map);
```
-The mapper initialized in the example above assumes a storm tuple has
value for all the columns.
-If your storm tuple only has fields for a subset of columns i.e. if some
of the columns in your table have default values
-and you want to only insert values for columns with no default values you
can enforce the behavior by initializing the
-`SimpleJdbcMapper` with explicit columnschema. For example, if you have a
user_details table
-`create table if not exists user_details (user_id integer, user_name
varchar(100), dept_name varchar(100), create_time TIMESTAMP DEFAULT
CURRENT_TIMESTAMP);`
-In this table the create_time column has a default value. To ensure only
the columns with no default values are inserted
-you can initialize the `jdbcMapper` as below:
+The mapper initialized in the example above assumes a storm tuple has
value for all the columns of the table you intend to insert data into and its
`getColumn`
+method will return the columns in the order in which Jdbc connection
instance's `connection.getMetaData().getColumns();` method returns them.
+**If you specified your own insert query to `JdbcInsertBolt` you must
initialize `SimpleJdbcMapper` with explicit columnschema such that the schema
has columns in the same order as your insert queries.**
+For example if your insert query is `Insert into user (user_id, user_name)
values (?,?)` then your `SimpleJdbcMapper` should be initialized with the
following statements:
```java
List<Column> columnSchema = Lists.newArrayList(
new Column("user_id", java.sql.Types.INTEGER),
- new Column("user_name", java.sql.Types.VARCHAR));
- JdbcMapper simpleJdbcMapper = new SimpleJdbcMapper(columnSchema);
+ new Column("user_name", java.sql.Types.VARCHAR),
--- End diff --
Codes in comments seems broken. Could you have a look?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---