First we will open our XAMPP server.
Then type localhost/phpmyadmin/ in the browser. After that we will create our database. After that, see below java code for setting up connection for the database.
Java Database Connectivity (JDBC) is an application programming interface (API) for the programming language Java, which defines how a client may access a database. It is Java based data access technology and used for Java database connectivity. It is part of the Java Standard Edition platform, from Oracle Corporation.
"jdbc:mysql://localhost:3306/newdatabase" ; here 3306 is the port number for XAMPP server and newdatabase is the name of our database.
Remember : First create the database, otherwise it won't connect simply by coding
These parts seem ok, but you will get error if you didn't add the appropriate library(ies) to the project using Netbeans's library facility. So, let's see how we can do that :
Following these steps properly will be enough for you to access your database.
See also:
Then type localhost/phpmyadmin/ in the browser. After that we will create our database. After that, see below java code for setting up connection for the database.
Java Database Connectivity (JDBC) is an application programming interface (API) for the programming language Java, which defines how a client may access a database. It is Java based data access technology and used for Java database connectivity. It is part of the Java Standard Edition platform, from Oracle Corporation.
"jdbc:mysql://localhost:3306/newdatabase" ; here 3306 is the port number for XAMPP server and newdatabase is the name of our database.
Remember : First create the database, otherwise it won't connect simply by coding
These parts seem ok, but you will get error if you didn't add the appropriate library(ies) to the project using Netbeans's library facility. So, let's see how we can do that :
- First Right-click on the project's root node in the Projects tab.
- In the pop-up context menu, click on Properties (on the bottom of the menu).
- Click on Libraries under Categories:. You should see the following screen:
- Click on the Add Library...
- Under Global Libraries click on MySQL JDBC Driver and then click the Add Library button. (If you don't have library named MySQL JDBC Driver, then simply download it from internet)
- Finally Click on OK.
Following these steps properly will be enough for you to access your database.
See also:
- Java MySQL INSERT (using Statement)
- Java MySQL DELETE (using Statement)
- Java MySQL SELECT (using Statement)
No comments:
Post a Comment