connector-j

ResultSetImpl throws NullPointerException

天涯浪子 提交于 2021-02-19 02:29:10
问题 i'm running mysql 5.5 with mysql 5.1.18 connector. a simple query of style select * from my_table where column_a in ('aaa','bbb',...) and column b=1; is executed from within java application. the query returns a resultset of 25k rows, 8 columns in each. while reading the results in while loop while(rs.next()) { MyObject c= new MyObject(); c.setA(rs.getString("A")); c.setB(rs.getString("B")); c.setC(rs.getString("C")); ... } a following exception is thrown, usually during the first loops, but

Does MySQL's Connector/J work with MariaDB?

只谈情不闲聊 提交于 2020-03-25 12:32:46
问题 I'm attempting to connect to my MariaDB database using Connector/J from here, but this fails to work and MariaDB logs ` "[Warning] Aborted connection 12 to db: 'enwikt_parsed' user: 'javawiki' host: 'localhost' (Got an error reading communication packets)". ` It occurs to me that I just assumed Connector/J from MySQL would just work with MariaDB, but now I'm not so sure. I know MariaDB has their own Java API/Connector, but I'm using someone else's code to parse wiktionary, and therefore can't

mysql connectorJ character set results does not support utf8mb4

*爱你&永不变心* 提交于 2019-12-25 18:11:33
问题 I m having a tomcat server having a connection pool to mysql. In the connection settings i can see all the character set encodings set to utf8mb4 in *this page except for character_set_results. My connection string being - jdbc:mysql://:3306/abc?character_set_server=utf8mb4&useOldAliasMetadataBehavior=true&character_set_connection=utf8mb4&characterEncoding=utf-8&character_set_results=utf8mb4 In the mysql server i can see character_set_results showing utf8mb4. But in the jsp page it is not

Counting INSERT/ON DUPLICATE KEY UPDATE

旧城冷巷雨未停 提交于 2019-12-13 04:47:22
问题 I have this sql query: INSERT INTO `Items` (`id`,`parent_id`,`name`) VALUES (123,321,null) ON DUPLICATE KEY UPDATE `id` = `id`, `parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`); I run the query with phpmyadmin, and it returns me right results: 0 - No update 1 - Line inserted 2 - Line updated But when I run the query via java/jdbc, the query returns 1-1-2 That is, 1 is returned when there's no insert/update at all. Any idea? Is it a bug or I just miss something? UPDATE: Latest

Does MySQL Connector/J driver implement JdbcRowSet interface?

岁酱吖の 提交于 2019-12-13 03:46:21
问题 I'm trying to get acquainted with JDBC basics throuhg Oracle's "The Java™ Tutorials" and now I got stuck right here: https://docs.oracle.com/javase/tutorial/jdbc/basics/jdbcrowset.html. For my examples, I exploit MySQL Server with the latest version of Connector/J (mysql-connector-java-8.0.16.jar). So far, the driver worked as expected. It gets connection to MySQL Server, creates database, tables, populates them with data and fills ordinary ResultSet objects with the retrieved data. However,

Java MySQL - Named Pipe connection throws warning on close

怎甘沉沦 提交于 2019-12-11 02:47:53
问题 I am connecting to MySQL in Java with Connector/J using Named Pipes. My connection and query are successful, but I am receiving a warning when I try to close the connection. I would like to know what I should do to fix whatever is causing the warning other than removing connection.close() (or removing the try-with-resources connection block and not adding a connection.close()). Here is my code for the query: public static List<List> QueryDB(int RowValue) { List<Long> ValueList = new ArrayList

Using getGeneratedKeys with batch inserts in MySQL with Connector/J

六眼飞鱼酱① 提交于 2019-11-30 22:03:30
问题 Using Connector/J, I would like to do a batch insert into a master table followed by a batch insert into a details table ( PreparedStatement.executeBatch() for both). I haven't found much information online, so I'm looking for any feedback from people that have experience with this. Can I use Statement.getGeneratedKeys() to get the IDs of the newly inserted rows in the master table so that I can use them as foreign keys in the detail inserts? What if not every query resulted in an insert (e.g

Correct way to keep pooled connections alive (or time them out and get fresh ones) during longer inactivity for MySQL, Grails 2 app

旧时模样 提交于 2019-11-27 11:34:02
I have a grails app that has flurries of high activity, but then often periods of inactivity that can last several hours to over night. I notice that the first users in the morning get the following type of exception, and I believe this is due to the connections in the pool going stale and MYSql database closing them. I've found conflicting information in Googling about whether using Connector/J connection property 'autoReconnect=true' is a good idea (and whether or not the client will still get an exception even if the connection is then restored), or whether to set other properties that will

Correct way to keep pooled connections alive (or time them out and get fresh ones) during longer inactivity for MySQL, Grails 2 app

本秂侑毒 提交于 2019-11-26 15:39:36
问题 I have a grails app that has flurries of high activity, but then often periods of inactivity that can last several hours to over night. I notice that the first users in the morning get the following type of exception, and I believe this is due to the connections in the pool going stale and MYSql database closing them. I've found conflicting information in Googling about whether using Connector/J connection property 'autoReconnect=true' is a good idea (and whether or not the client will still