iReport error SQLException: Database not selected

2019-07-25 07:28发布

问题:

I'm working with iReport 5.6.0 to build some report templates. I'm having an issue when trying to retrieve some data from the DB. The DBMS is Informix and the procedure I'm doing is the following:

1. Add the Informix JDBC driver which I downloaded from Maven Central (com.ibm.informix:jdbc)

2. Create a datasource with the driver and the JDBC's URL. Test the connection and it's successful

3. In the Report query window I write a query and in the result pane (at the bottom) I get and error as you can see in the image below

Am I missing something here? Where should I look? As I said the connection test to the DB is successful.

Thanks in advance for your answers.

回答1:

After doing a deep search in the Informix JDBC documentation I found this section where I found the correct syntax for the URL, which is

jdbc:informix-sqli://<host>:<port>/<dbName>:INFORMIXSERVER=<serverName>;user=<username>;password=<password>

Previously I was using the syntax shown in the screenshot below and providing credentials in the dialog instead of the URL.

I don't know why the connection test was successful with the wrong syntax. Perhaps the test only pings the host and the port, without checking the connection parameters.

Hope this helps someone. Best regards.

PS: Thanks to user Jonathan Leffler, your comment helped me to find the solution