jdbc

Java parsing String to a Date returns incorrect Date

我是研究僧i 提交于 2021-01-27 15:58:50
问题 I am storing my 2 Java date types as Date and Time for a MySQL database table. I am using the SimepleDateFormat("YYYY-MM-dd") to store the date in my database and it shows up as the correct date when i go to select it. However when i try to parse it back into a util.Date and create a new Event Object, it shows up as 30/12/2012 instead of 31/05/2013 as it is in the database. The time, when parsed into a util.Date and formatted prints out correctly. I am not sure why the Date is printing the

Does `serverTimezone` param change @@session.time_zone in MySQL?

非 Y 不嫁゛ 提交于 2021-01-27 14:16:17
问题 If I'm making a connection to MySQL with serverTimezone=UTC in my connection URL, will that change the @@session.time_zone variable for my connection to MySQL? Or is the only way to alter @@session.time_zone through issuing a SET time_zone... statement? I was lead to believe that the combination of serverTimezone=UTC and useLegacyDateTimeCode=false would set the @@session.time_zone to UTC (or whatever timezone I passed in as an argument to serverTimezone ) but testing this behaviour with

“ORA-00922: missing or invalid option” when trying to insert into table

試著忘記壹切 提交于 2021-01-27 11:37:15
问题 When i run SQL query in oracle sql developer it is work, but in jdbc this query doesn't work and catch the java.sql.SQLSyntaxErrorException: ORA-00922: missing or invalid option. Could anyone help me ? There is my query below CREATE GLOBAL TEMPORARY TABLE MY_TABLE ( ID VARCHAR2(30 BYTE) PRIMARY KEY, NAME VARCHAR2(20 BYTE)); INSERT INTO MY_TABLE ( ID, NAME) VALUES ('My_Id' , 'My_Name' ); 回答1: It is just a quick guess, because I have no oracle available to proof it, but with MyBatis (which is

Timestamp discrepancies between SQL server and Java

不打扰是莪最后的温柔 提交于 2021-01-27 07:54:16
问题 I need to replicate a simple procedure from Java code to SQL Server stored procedure. It will go into a SQL Azure db in production, but I'm testing it against my local SQL Express 12 install. A part of this stored procedure is to concatenate some values into a string. This is my example Java code: import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import com.google.common.base.Strings; public static String concat() { /

Timestamp discrepancies between SQL server and Java

。_饼干妹妹 提交于 2021-01-27 07:53:09
问题 I need to replicate a simple procedure from Java code to SQL Server stored procedure. It will go into a SQL Azure db in production, but I'm testing it against my local SQL Express 12 install. A part of this stored procedure is to concatenate some values into a string. This is my example Java code: import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import com.google.common.base.Strings; public static String concat() { /

Java how to retrieve more than 1 million rows in a Resultset

倖福魔咒の 提交于 2021-01-27 07:22:15
问题 I am executing select query on a table of MYSQL which has 16,213,156 rows and 10 columns. But after connection is established code just executes for few mins and then throws error : Exception in thread "Thread-3" java.lang.OutOfMemoryError: Java heap space My system configuration is 16 gb RAM, Java 8 I tried setting Jvm Parameters as -Xms4G & -Xmx12G . Also tried setting stmt.setFetchSize(); // to 10,100,1000 still same error Can we fetch such large number of records using JDBC API am I

Java how to retrieve more than 1 million rows in a Resultset

会有一股神秘感。 提交于 2021-01-27 07:20:56
问题 I am executing select query on a table of MYSQL which has 16,213,156 rows and 10 columns. But after connection is established code just executes for few mins and then throws error : Exception in thread "Thread-3" java.lang.OutOfMemoryError: Java heap space My system configuration is 16 gb RAM, Java 8 I tried setting Jvm Parameters as -Xms4G & -Xmx12G . Also tried setting stmt.setFetchSize(); // to 10,100,1000 still same error Can we fetch such large number of records using JDBC API am I

Get table return value from PL/SQL stored function using JDBC

喜你入骨 提交于 2021-01-27 06:30:53
问题 I have a PL/SQL stored function which returns a table of integers: CREATE TYPE INT_TABLE IS TABLE OF INTEGER; CREATE FUNCTION f (someParam IN INTEGER) RETURN INT_TABLE IS ... I wish to use JDBC to retrieve the result of this function so that I can iterate through the integers in some way, be it a ResultSet , int[] , or whatever. The function f performs modifications to the database, so it cannot be called in a query such as SELECT f(42) FROM DUAL; . The return value exists to inform the

Issue establishing a database connection with a char array instead of a String

主宰稳场 提交于 2021-01-27 06:23:23
问题 As the title says, I'm looking into finding a way to use a char[] array to establish a JDBC connection instead of creating a new String object from the char[] array and using that to establish the connection. Because char[] arrays are more secure than Strings in java, I've been wanting to keep things as secure as possible when dealing with my JPasswordFields. In this particular case, I'm taking the char[] array contents of a JPasswordField and attempting to establish a JDBC connection to a

JDBC: Get table names involved in a SQL query

前提是你 提交于 2021-01-27 04:46:34
问题 Is there any way to know the name of the tables involved in a SQL query executed via JDBC? For example: SELECT r.roleId FROM User u, UserRole r where r.userId = u.userId and u.name = "Jonh Smith" I don't want only the result set of this query but the actual table names ("User" and "Role"). I don't care about view names, but if there is no way to get the underlying table used in the view it's not a big problem, but this has to work with nested queries. As for why I need this information it's