0

This is my first time using jasperserver and I want to connect to mysql databae, I have been following tutorial videos and looking at the documents but I don't understand where do you get the JDBC Driver and URL. They give the hint: Hint: jdbc:postgresql://localhost:5432/mydb and also Hint: org.postgresql.Driver but I still don't know where to look for it.

I have already downloaded the drivers using this website, https://learn.microsoft.com/en-us/sql/connect/sql-connection-libraries#anchor-20-drivers-relational-access and transfer sqljdbc42 and sqljdbc41 into apache tomcat/lib folder already

Can someone please guide me in doing this? Thanks a lot.

Dkna
  • 409
  • 3
  • 15
  • 37
  • You tag with MySQL, but you talk about PostgreSQL and MS SQL Server in your question. Why? – Mark Rotteveel Dec 04 '17 at 12:07
  • @MarkRotteveel I want to connect to mysql server but because there are other different kind of server I am kind of confused with what to use under driver and url but Whome has already answered my question. And in my question, which part did I say about MS SQL or PostgreSQL, sorry still learning this part, if you are saying at the hint part, that is just an example – Dkna Dec 05 '17 at 00:32
  • You are talking about PostgreSQL in your first paragraph, and linking to Microsoft SQL Server JDBC driver documentation in your second paragraph. As a first step when searching, make sure you exclude results about other database systems. – Mark Rotteveel Dec 05 '17 at 10:09

1 Answers1

2

Each SQL server has a different jdbc url format.

MySQL (and also MariaDB), driver=com.mysql.jdbc.Driver

jdbc:mysql://127.0.0.1:3306/mydb?useUnicode=true&characterEncoding=utf8&user=myuser&password=mypwd

MSSQL, driver=com.microsoft.jdbc.sqlserver.SQLServerDriver

jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=mydb;user=myuser;password=mypwd

Whome
  • 10,181
  • 6
  • 53
  • 65
  • Is the port number in this case fixed? For the MySQL and can I also know the difference betwwen MSSQL and MySQL. Which do I use? – Dkna Dec 04 '17 at 09:24
  • If possible, can I have the format for the URL? Because I have seen many different format and I don't know which to use, for example, jdbc:mysql://:/ – Dkna Dec 04 '17 at 09:27
  • 1
    3306 is the default port number for MySQL. Unless you have it running on a non-default port, omit it. – user207421 Dec 04 '17 at 09:40
  • @Dkna You use an approriate jdbc url based on the sql server engine. So if you have MySQL(mariadb) then use mysql syntax, if you have MSSQL then use mssql syntax. – Whome Dec 04 '17 at 10:06
  • Thank you for helping everyone, it finally work :) – Dkna Dec 05 '17 at 00:32
  • MariaDB has their own JDBC driver and JDBC url, it is just that (for now?) the MySQL driver also works with MariaDB. – Mark Rotteveel Dec 05 '17 at 10:09