❶ 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();
}
}
}
注意:一定要区分大小写,而且符号要是在英文状态的。