Simple JDBC Connection for local MySQL DB on Windows Machine?

I am using Jaspersoft Studio 6.40 and I am trying to determine the easiest way to connect to a local MySQL DB on a windows machine in order to create reports.  The JRXML file will be uploaded Jasperserver running AWS Linux.  The MySQL DB is stored in a folder on a Windows 10 machine, that is also running Jasper Studio.

I went to create an adapter, chose the JDBC connection, which I am assuming is the proper Data Adapter.

What is the best driver to use for JDBC? What should be the JDBC Url? For example, if the MySQL DB is located in c:\mydatabase, what would the url be? Do I need to run VMWare or something similar to create a localhost




Kendjr's picture
Joined: Aug 4 2013 - 12:23pm
Last seen: 5 years 5 months ago

Thank you.  How do I "load" the database and localhost? Do I need to start MySQL Workbench before I load Studio? Do I need something like VMWare loaded in order to tell Studio where localhost is?

Kendjr - 5 years 6 months ago

localhost is a standard syntax that indicates the current machine.  You do not do anything to create it. You need to have the database up and running, but nothing else.

I suspect you're expecting something fancier when you create the data adapter.  When you set up the data adapter as below, click Test and you will get a response saying if the adapter is valid. You don't have any insight into the database content when you create the adapter.

Once you have an adapter, you can use it in a report.  Read the documentation section on "creating a simple report" to see how to create a report and choose an adapter.  Once you use your adapter in a report, you can create an SQL query to select the data for the report. You will see a simple interface that shows you the available fields, but if you need an advanced tool to create a complex query, it might be best to create the query outside JSS and copy it into the Dataset and Query dialog for the report. 

If you want to upload your report to JasperReports Server, you need to either create a new data source on your JRS that connects to the database or you need to make sure that your data adapter in JSS is local, not global, and then it will publish as a resource when you publish the report.  

elizam - 5 years 6 months ago

Sorry, but I am trying to determine the easiest way to get the DB "up and running".  I have a .sql file on a Windows machine.  If I can connect to it on MySQL workbench, what url do I use? for example, something like 
JDBC Url: jdbc:mysql://localhost/mydatabasename, or is it something like jdbc:file://localhost/mydatabasename

Or is it creating a new DB inside of Jasper Studio, and then importing the sql file?

I just want the easiest way since the local machine is not using the DB for anything other than Jasper Studio, and does not need to have a virtual machine for any other purpose.


Kendjr - 5 years 6 months ago

2 Answers:

If you're using MySQL, user MySQL Connector/J


JDBC Driver: com.mysql.jdbc.Driver

JDBC Url: jdbc:mysql://localhost/<database name>

hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 9 months ago
It works!
sespang's picture
Joined: Dec 12 2019 - 12:46am
Last seen: 3 years 3 months ago