❶ myeclipse怎麼把數據添加到資料庫啊
首先打開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直接連接sql server怎麼連接
1.工作區切換
Open
perspective
-->
Myeclipse
database
explorer
2.新建:輸入【鏈接名稱】,【資料庫鏈接驅動】,【資料庫url】,【資料庫username】,【資料庫password】,點擊【finish】按鈕。
3.啟動資料庫
4.使用myeclipse鏈接資料庫(右鍵點擊剛剛建立的鏈接【open
connection】)
❸ myeclipse怎麼連資料庫
myeclipse連接mysql資料庫的方法如下:
1、在myEclipse中,Window—>Open Perspective—>MyEclipse Database Explorer。打開之後左側會出現下圖所示界面,在空白區域右擊——New。
2、選中所建的DB,右擊Open Connection,輸入用戶名和密碼。
❹ 在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怎麼鏈接資料庫
window-》show view->other->myeclipse database->db browser
1.在db browser里點擊右鍵new
2。driver template里選microsoft sql server2005
driver name:隨便填一個
url:jdbc:sqlserver://localhost:埠號;databaseName=XX
username和password就添能訪問該資料庫的
3.然後點擊add jars選擇sql server驅動
4.往下選擇save password
5.狂點next到只能點finish為止
6.回到db browser可以看見你創建的sql server,對它點擊右鍵選擇open就連上了
❻ myeclipse怎樣連接mysql資料庫
點在裡面右鍵選擇new 新建個連接,就能連資料庫了
❼ myeclipse怎麼連接資料庫mysql
Java連接mysql資料庫,首先需要導入mysql的java驅動,然後在Java程序中寫一個連接串,程序裡面調mysql提供的一些函數來執行一些查詢;
❽ 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資料庫
首先打開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與資料庫連接了
public class DBConnection {
private static final String DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String URL ="jdbc:sqlserver://localhost:1433(這個是埠號);databastName=你的資料庫名字";
private static final String USER = "sa";//這個代表你的資料庫登錄名
private static final String PWD = "";//這個代表你的資料庫登錄密碼,一般是空的。
private Connection con = null;
public DBConnection(){
try {
Class.forName(DRIVER);//載入資料庫驅動
con = DriverManager.getConnection(URL,USER,PWD);//連接資料庫
System.out.println("資料庫連接成功");
} catch (SQLException e) {
System.out.println("驅動載入失敗");
// TODO Auto-generated catch blo-QWAwaaAck
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
System.out.println("資料庫連接失敗");
e.printStackTrace();
}
}
public Connection getConnection(){
return con;
}
public void close(){
try {
this.con.close();
System.out.println("資料庫成功關閉");
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("資料庫關閉失敗");
e.printStackTrace();
}
}
}
這里要注意一定要區分大小寫,而且符號要是在英文狀態的。重要的是:還要倒一個架包,這個有點麻煩。
❿ myeclipse中如何連接資料庫,怎樣才能知道資料庫是否連接成功
myeclipse連接資料庫成功或失敗後都會有提示的,具體連接方法如下:
public class DBConnection {
private static final String DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String URL ="jdbc:sqlserver://localhost:1433(這個是埠號);databastName=你的資料庫名字";
private static final String USER = "sa";//這個代表你的資料庫登錄名
private static final String PWD = "";//這個代表你的資料庫登錄密碼,一般是空的。
private Connection con = null;
public DBConnection(){
try {
Class.forName(DRIVER);//載入資料庫驅動
con = DriverManager.getConnection(URL,USER,PWD);//連接資料庫
System.out.println("資料庫連接成功");
} catch (SQLException e) {
System.out.println("驅動載入失敗");
// TODO Auto-generated catch blo-QWAwaaAck
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
System.out.println("資料庫連接失敗");
e.printStackTrace();
}
}
public Connection getConnection(){
return con;
}
public void close(){
try {
this.con.close();
System.out.println("資料庫成功關閉");
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("資料庫關閉失敗");
e.printStackTrace();
}
}
}
注意:一定要區分大小寫,而且符號要是在英文狀態的。