當前位置:首頁 » 數據倉庫 » myeclipse中連接mysql資料庫
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

myeclipse中連接mysql資料庫

發布時間: 2022-08-24 02:11:24

㈠ myeclipse怎麼連接mysql資料庫

myeclipse連接mysql資料庫的方法如下:

1、在myEclipse中,Window—>Open Perspective—>MyEclipse Database Explorer。打開之後左側會出現下圖所示界面,在空白區域右擊——New。

2、選中所建的DB,右擊Open Connection,輸入用戶名和密碼。

㈡ myeclipse怎麼連資料庫

myeclipse連接mysql資料庫的方法如下:

1、在myEclipse中,Window—>Open Perspective—>MyEclipse Database Explorer。打開之後左側會出現下圖所示界面,在空白區域右擊——New。

2、選中所建的DB,右擊Open Connection,輸入用戶名和密碼。

㈢ MyEclipse如何連接MySQL資料庫

寫一個DBconnect類,裡面寫資料庫引擎,資料庫名稱,密碼,然後在導入mysql的jdbc的驅動包,就可以了

㈣ 用MYECLIPSE怎麼連接MYSQL資料庫

首先打開Myeclipse
在工具欄上選擇
window->Show View->Other
選擇Myeclipse database
雙擊DB Bowser
在控制台部分多出DB Bowser,右擊空白處
選擇new
在彈出的界面中
Driver template:MySQL Connector/]
Driver name:填寫連接的名字(隨意)
Connection url:jdbc:mysql://localhost:3306/資料庫名
其中localhost表示本地資料庫,如果是遠程的則填寫對方地址
資料庫名表示你要連接的資料庫的名稱
User name:root
password:密碼
然後添加jar包
這個時候你可以測試一下連接
單擊Test Driver
如果連接成功則點擊finsh
然後在控制台處
右擊你的連接名
選擇open connection
這樣你就將Myeclipse與資料庫連接了!

㈤ 在myeclipse中怎麼連接mysql資料庫

JDBC連接各種資料庫的方法

1)連接Oracle 8/8i/9i/10g/11g(thin模式)

Class.forName("oracle.JDBC.driver.OracleDriver").newInstance();
Stringurl="JDBC:oracle:thin:@localhost:1521:orcl"//orcl為Oracle資料庫的SID
Stringuser="test";
Stringpassword="test";
Connectioncon=DriverManager.getConnection(url,user,password);

2)連接DB2資料庫

Class.forName("com.ibm.db2.jcc.DB2Driver");
Stringurl="JDBC:db2://localhost:5000/testDb";/**資料庫連接串**/
Stringuser="test";Stringpassword="test";
Connectioncon=DriverManager.getConnection(url,user,password);

3)連接MySQL資料庫

Class.forName("com.mysql.jdbc.Driver");
Stringurl="JDBC:mysql://localhost:8080/testDB";
Stringuser="test";Stringpassword="test";
Connectioncon=DriverManager.getConnection(url,user,password);

4)連接SQL Server資料庫

Class.forName("com.microsoft.JDBC.sqlserver.SQLServerDriver");
Stringurl="JDBC:microsoft:sqlserver://localhost:1433;DatabaseName=testDb";
Stringuser="test";Stringpassword="test";
Connectioncon=DriverManager.getConnection(url,user,password);

5)連接PostgreSQL資料庫

Class.forName("org.postgresql.Driver");
Stringurl="JDBC:postgresql://localhost/testDb";
Stringuser="test";Stringpassword="test";
Connectioncon=DriverManager.getConnection(url,user,password);

6)連接Access資料庫

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Stringurl="JDBC:odbc:Driver={MicrosoftAccessDriver(*.mdb)};DBQ="+application.getRealPath("/Data/testDb/mdb");
Connectionconn=DriverManager.getConnection(url,"","");

7連接Sybase資料庫

Class.forName("com.sybase.JDBC.SybDriver");
Stringurl="JDBC:sybase:Tds:localhost:5007/testDb";
Propertiespro=System.getProperties();
pro.put("user","userId");
pro.put("password","user_password");
Connectioncon=DriverManager.getConnection(url,pro);

8連接informix資料庫

Class.forName("com.informix.JDBC.ifxDriver");
Stringurl="JDBC:informix-sqli:localhost:1533/testDb:INFORMIXSERVER=myserver"user=testUser;password=testpassword";Connectioncon=DriverManager.getConnection(url);

示例:我這里有個大牛聚集地,前面九七三中間打四五四後面兩個零,組合起來就行了。連接SQL Server2008R2資料庫
首先Build Path → 添加外部sqljdbc.jar驅動

import java.sql.*;

public class DB {

public static void main(String[] args) throws Exception {

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433; DatabaseName=資料庫名", "sa", "1234");

Statement stmt = conn.createStatement();

ResultSet rs = stmt.executeQuery("select * from 表名");

while(rs.next()) {

System.out.println("id為:" + rs.getString("id") + "name為:" + rs.getString("name"));

}

System.out.println("資料庫連接成功!");

rs.close();

stmt.close();

conn.close();

System.out.println("資料庫成功關閉!");

}

}

㈥ 怎麼用myeclipse連接mysql資料庫

myeclipse連接mysql資料庫的方法如下: 1、在myEclipse中,Window—>Open Perspective—>MyEclipse Database Explorer。打開之後左側會出現下圖所示界面,在空白區域右擊——New。 2、選中所建的DB,右擊Open Connection,輸入用戶名和密碼。 3、就...

㈦ myeclipse怎麼連接資料庫mysql

Java連接mysql資料庫,首先需要導入mysql的java驅動,然後在Java程序中寫一個連接串,程序裡面調mysql提供的一些函數來執行一些查詢;