jdbc

Crystal reports - connection to JDBC failed

ⅰ亾dé卋堺 提交于 2021-01-28 08:21:29
问题 I am trying to make a connection to JDBC(JNDI) in Crystal Reports and I get the following error : Invalid Argument provided. Details: Java Server startup failure. Please verify the PATH (JDK), CLASSPATH and IORFileLocation properties in the CRConfig.xml file. In addition, please verify you are using JDK 1.4. I am using the connector : mysql-connector-java-5.1.6-bin.jar, jDK 1.6. Thank you! 回答1: I finally found the problem! The directory associated to IORFileLocation (which is C:\Windows\temp

How to fix: “Parameter index out of range (2 > number of parameters, which is 1).”

旧时模样 提交于 2021-01-28 07:47:31
问题 If i try to get the timeStamps (Date object) from my mySql database via Java (jdbc) i get the error: "Parameter index out of range (2 > number of parameters, which is 1)." I can´t find a solution on the internet that works for me, because (i think) the sql-query is correct and i placed the exact number of '?' needed. PreparedStatement st = conn.prepareStatement("SELECT * FROM timestamp WHERE stampTime BETWEEN '?/0/? 00:00:00.00' AND '?/31/? 23:59:59.999' AND userid = ? "); st.setInt(1, month)

getString from ResultSet with spaces

喜夏-厌秋 提交于 2021-01-28 07:09:34
问题 I'm managing a JDBC database with Servlets/JSPs and one of the attributes I have in a table is a string which may or may not have spaces in between words. I have one JSP to display all the information and another one to edit it, on both I perform getString to a ResultSet and when I'm just displaying it it works fine, but on the edit JSP it only "grabs" the first word before the space and the rest of the string disappears. Here's part of the code: PerfilUsuarioConectado.jsp (the one I use to

“Invalid connection string format” error when trying to connect to Oracle using TNS alias that contains dot character

匆匆过客 提交于 2021-01-28 06:56:46
问题 I am trying to connect to Oracle database using TNS. The problem is that TNS alias contains dot, so when I am specifying url like this: jdbc:oracle:thin:@TNS.ALIAS I've got... oracle.net.ns.NetException: Invalid connection string format, a valid format is: "host:port:sid" ...during creation of connection. I know that dot character is a problem, because after removing it from tnsnames.ora file connection to database works. My question is - is it possible to escape dot character somehow? Maybe

How to Use HikariCP with MySql JDBC

安稳与你 提交于 2021-01-28 04:29:42
问题 I'm trying to use HikariCP JDBC connection pool in my Java application. I'm not using any frameworks like Spring or Hibernate in my application. Currently I'm able to connect to MySQL DB using simple JDBC driver but when I try using Hiraki the code is not working. Can't understand where I'm going wrong even after initializing the data source . Initial JDBC Working Code.. public class Connect extends ErrorCat{ protected Connection connection = null; //Database user name and password private

How to Use HikariCP with MySql JDBC

点点圈 提交于 2021-01-28 04:23:30
问题 I'm trying to use HikariCP JDBC connection pool in my Java application. I'm not using any frameworks like Spring or Hibernate in my application. Currently I'm able to connect to MySQL DB using simple JDBC driver but when I try using Hiraki the code is not working. Can't understand where I'm going wrong even after initializing the data source . Initial JDBC Working Code.. public class Connect extends ErrorCat{ protected Connection connection = null; //Database user name and password private

Java ResultSet.getString() for Date field displaying 00:00:00.0

走远了吗. 提交于 2021-01-28 00:00:45
问题 I am using a generic method to loop through and convert a ResultSet to a String array. I am wondering why does the Date column in Oracle db value come print out as 2015-01-09 00:00:00.0 while the date in the database shows 2015-01-09 ? Here is the code, the col type in Oracle is Date while(rs.next()) { String[] arr = new String[colCount]; for(int i = 1; i <= colCount; i++) { arr[i-1] = rs.getString(i); }//end for list.add(arr); }//end while So that is part 1 of the question, part 2 of the

Eclipselink - @CascadeOnDelete doesn't work on @OneToOne relations

故事扮演 提交于 2021-01-27 18:17:20
问题 I have two relations in my class: @OneToOne(mappedBy = "poi", cascade = { CascadeType.ALL }) @CascadeOnDelete protected PoiDescription description; @OneToMany(mappedBy = "poi", cascade = { CascadeType.ALL }) @CascadeOnDelete protected List<PoiAdditional> additionals = new ArrayList<>(); In my generated DDL (for postgres) I becomes: ALTER TABLE POI_DESCRIPTION ADD CONSTRAINT FK_POI_DESCRIPTION_POI_ID FOREIGN KEY (POI_ID) REFERENCES POI (ID) ALTER TABLE POI_ADDITIONAL ADD CONSTRAINT FK_POI

Eclipselink - @CascadeOnDelete doesn't work on @OneToOne relations

时光总嘲笑我的痴心妄想 提交于 2021-01-27 18:05:27
问题 I have two relations in my class: @OneToOne(mappedBy = "poi", cascade = { CascadeType.ALL }) @CascadeOnDelete protected PoiDescription description; @OneToMany(mappedBy = "poi", cascade = { CascadeType.ALL }) @CascadeOnDelete protected List<PoiAdditional> additionals = new ArrayList<>(); In my generated DDL (for postgres) I becomes: ALTER TABLE POI_DESCRIPTION ADD CONSTRAINT FK_POI_DESCRIPTION_POI_ID FOREIGN KEY (POI_ID) REFERENCES POI (ID) ALTER TABLE POI_ADDITIONAL ADD CONSTRAINT FK_POI

JDBC with try with resources

匆匆过客 提交于 2021-01-27 17:18:05
问题 I am trying to create a centralized class that connects and returns the ResultSet of a SQL query so that I don't always have to create a new connection every time I am trying to get a query. I am using the try-with-resources , however, I am getting a compile-time error whenever I use the try-with-resources and I don't know why? public class JDBC { // logger declaration is omitted private static final String dbURL = "jdbc:oracle:"; private static final String userName = "blah"; private static