Skip to content
Advertisement

Where can I find MySQL Path/URL for NetBeans?

I’m trying to do school JAVA EE project and I have to connect schema made in mysql from MYSql.

part of code is (for SQL select) :

String dbURL = "";
String user = "root";
String password = "root";

and i apperently have no URL somehow

Any ideas on that? I’m new to SQL and JAVA EE so i face lots of problems :/

Advertisement

Answer

First of all you need a running mysql instance. There are 2 possibilities :

(1) You need the domain :

  • local instance / domain : localhost
  • Remote instance / domain or IP

(2) You need the port of the mysql server instance

  • Default is 3306

(3) The name of the database you want to connect to.

  • Lets say you need to connect to the database test

Now in order to connect to the database you will need to generate the connection url. In our case since (I assume) you want to write java, the url is in jdbc format

jdbc:mysql://localhost:3306/test

In order to connect netbeans to a mysql Database you will need to follow the next steps :

  1. Locate the service tab on the project tab and right click on the Databases. enter image description here
  2. Select the Mysql Driver and click next. (If the driver misses just download the file from the suggested portal it will be a jar). enter image description here enter image description here
  3. Finally fill the appropriate information on the next frame enter image description here

If you need parameters to your jdbc URL you can do so like :

jdbc:mysql://localhost:3306/test?param1=value1

You can find more detailed information on the Netbeans website : https://netbeans.org/kb/docs/ide/mysql.html

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement