Home > Database > navicat > body text

How to connect myeclipse to navicat

爱喝马黛茶的安东尼
Release: 2019-08-15 16:06:28
Original
15590 people have browsed it

How to connect myeclipse to navicat

Steps to connect myeclipse to navicat:

1. Install mysql

2. Install myeclipse

3. Install mysql visual interface Navicat

4. Download JDBC driver Download address https://dev.mysql.com/downloads/connector/j/

5 .Configure the connection (key point)

1> Place the JDBC driver in the lib package under the new project (if there is no such folder, create it yourself), and then set it into the environment (right-click the jar file Then Build Path).

2>Open myeclipse-Window-perspective-Open Perspective-Myeclipse Database Explorer.

Related recommendations: "Navicat for mysql graphic tutorial"

3> After opening it, right-click on the blank version on the right side - New, and the following screen will appear requiring configuration information.

How to connect myeclipse to navicat

4> The configuration information is as follows:

(Note two points: 1.jdbc:mysql://[<:3306> ]/ To modify 2. Driver classname, select the one below)

How to connect myeclipse to navicat

Then Finish if the Test Driver is successful.

5>Write java code to access the database.

public class DBUtil {
private static final String URL="jdbc:mysql://127.0.0.1:3306/testdatabase";
private static final String USER="root";
private static final String PASSWORD="";
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
//1.加载驱动程序
Class.forName("com.mysql.jdbc.Driver");
//2.获得数据库连接
Connection conn=DriverManager.getConnection(URL, USER, PASSWORD);
//3.通过数据库的连接操作数据库,实现增删改查
Statement stmt = conn.createStatement();
ResultSet rs=stmt.executeQuery("select user_name,age from goddess where id=1");
while(rs.next()){
System.out.print(rs.getString("user_name")+","+rs.getInt("age"));
}
 
}
 
}
Copy after login

The database is as shown in the figure:

How to connect myeclipse to navicat

Finally, the java code was successfully run.

How to connect myeclipse to navicat

The above is the detailed content of How to connect myeclipse to navicat. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!