TIBCOSoftware / jasperreports

JasperReports® - Free Java Reporting Library
https://community.jaspersoft.com/downloads/community-edition/
GNU Lesser General Public License v3.0
1.04k stars 401 forks source link

Studio does not honor JDBC url database parameter #128

Closed deceiver08 closed 4 years ago

deceiver08 commented 4 years ago

When I try to create a data adapter to a Azure SQL database, the connection always goes to the master database rather than the database I specify in the jdbc url using the databaseName parameter (I also tried just "database" too for the parameter and it didn't work either). The user I am using does have rights to the database called out. I can't move forward.

teodord commented 4 years ago

What is the JDBC driver (name and version) that you are using?

deceiver08 commented 4 years ago

mssql-jdbc-8.2.2.jre8.jar

deceiver08 commented 4 years ago

image

This is the master database. Not the db I specify in the connection string. image

teodord commented 4 years ago

I am not familiar with how this driver works, but just by reading its documentation, seems that the URL parameter is called "databaseName": https://docs.microsoft.com/en-us/sql/connect/jdbc/using-the-jdbc-driver?view=sql-server-ver15

JasperReports is not doing anything with the URL and it passes it to the driver, which is responsible to make use of it, the way it sees fit.

You should try use the driver with some other Java applications to see if it works there. I suggest a Java SQL tool such as Squirrel. http://squirrel-sql.sourceforge.net/

So let's put aside JRL and JSS for a moment and see if the driver actually works as advertised.

deceiver08 commented 4 years ago

Hi @teodord. Yeah I caught that. I use the databaseName parameter. Sorry for the confusion.

I did as you suggested and Squirrel connects just fine using the driver. As you can see, in Squirrel both databases are presented, whereas in Jasper Studio its just master. I am literally using the exact same connection strings between the two software?

deceiver08 commented 4 years ago

If you are aware of a different java driver that will work with an Azure Sql database in Studio, let me know. At the moment, this java driver is the latest and greatest from Microsoft directly.

teodord commented 4 years ago

Looks like this Squirrel test did not help us much after all. From what I can see, the fact that you provided the databaseName to the Squirrel URL did not make it see only that database. Squirrel will see all databases anyway. Probably even if you don't specify a databaseName at all, right?

deceiver08 commented 4 years ago

You are right. I stripped out the databaseName parameter and Squirrel still presented me with both databases. I tried the same thing in Studio and it still shows just master. So if they are both using the same driver, is something in Studio hardcoded to filter or only present one db regardless of driver? image

deceiver08 commented 4 years ago

I finally got this working. I dropped and recreated the user I was trying to connect with and it worked. Looks like it was a sql server security issue, probably with the assigned login role.

teodord commented 4 years ago

Thanks for letting us know.