apache-commons-dbutils

Apache Dbutils changing column name in update Sql

狂风中的少年 提交于 2019-12-07 05:41:58
问题 I am having a strange problem with Dbutils , I am trying to run a parameterized update sql, I am supplying correct number of arguments , but dbutils is modifying the timestamp column name by changing the name of modifying it when timestamp columnname is one alphabet java.sql.SQLException: Wrong number of parameters: expected 4, was given 5 Query: UPDATE WEATHER_2 SET WEATHER=? , O=TO_TIMESTAMP(?,'YYYY-MM-DD HH24:MI:SS.FF') , HUMIDITY=? , TEMP=? WHERE ID=? Parameters: [804, 2015-06-05 17:21:05

Apache Dbutils changing column name in update Sql

时光总嘲笑我的痴心妄想 提交于 2019-12-05 11:44:10
I am having a strange problem with Dbutils , I am trying to run a parameterized update sql, I am supplying correct number of arguments , but dbutils is modifying the timestamp column name by changing the name of modifying it when timestamp columnname is one alphabet java.sql.SQLException: Wrong number of parameters: expected 4, was given 5 Query: UPDATE WEATHER_2 SET WEATHER=? , O=TO_TIMESTAMP(?,'YYYY-MM-DD HH24:MI:SS.FF') , HUMIDITY=? , TEMP=? WHERE ID=? Parameters: [804, 2015-06-05 17:21:05.809, 16.0, 25.15, 1347927] when timestamp columnname is normal..it will ommit the second alphabet java

How to get generated keys with commons dbutils?

若如初见. 提交于 2019-12-01 16:45:24
I don't understand how to get auto generated keys with commons-dbutils? You can use QueryRunner#insert() . Below is an example. Given a table called users , which has an auto generated primary key column and a varchar column called username , you can do something like this: DataSource dataSource = ... // however your app normally gets a DataSource QueryRunner queryRunner = new QueryRunner(dataSource); String sql = "insert into users (username) values (?)"; long userId = queryRunner.insert(sql, new ScalarHandler<Long>(), "test"); As a matter of fact I think it cannot be done with the current

How to get generated keys with commons dbutils?

夙愿已清 提交于 2019-12-01 15:31:09
问题 I don't understand how to get auto generated keys with commons-dbutils? 回答1: You can use QueryRunner#insert(). Below is an example. Given a table called users , which has an auto generated primary key column and a varchar column called username , you can do something like this: DataSource dataSource = ... // however your app normally gets a DataSource QueryRunner queryRunner = new QueryRunner(dataSource); String sql = "insert into users (username) values (?)"; long userId = queryRunner.insert

DBUtils fails to fill fields of a Java Bean

♀尐吖头ヾ 提交于 2019-12-01 02:20:43
I have a mysql table like this: CREATE TABLE `sezione_menu` ( `id_sezione_menu` int(11) unsigned NOT NULL AUTO_INCREMENT, `nome` varchar(256) NOT NULL DEFAULT '', `ordine` int(11) DEFAULT NULL, PRIMARY KEY (`id_sezione_menu`) )ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; I use apache dbutils to query my database, with these methods: public static List<SezioneMenu> getSezioniMenu() { String sql = "SELECT * FROM sezione_menu"; try { QueryRunner qr = new QueryRunner(createDataSource()); ResultSetHandler rsh = new BeanListHandler(SezioneMenu.class); List<SezioneMenu> sezioni = (List

DBUtils fails to fill fields of a Java Bean

时间秒杀一切 提交于 2019-11-30 20:41:13
问题 I have a mysql table like this: CREATE TABLE `sezione_menu` ( `id_sezione_menu` int(11) unsigned NOT NULL AUTO_INCREMENT, `nome` varchar(256) NOT NULL DEFAULT '', `ordine` int(11) DEFAULT NULL, PRIMARY KEY (`id_sezione_menu`) )ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; I use apache dbutils to query my database, with these methods: public static List<SezioneMenu> getSezioniMenu() { String sql = "SELECT * FROM sezione_menu"; try { QueryRunner qr = new QueryRunner(createDataSource());