Configuring Database Access in Eclipse 3.0 wi…
2008-02-23 09:44:52来源:互联网 阅读 ()
Configuring Database Access in Eclipse 3.0 with SQLExplorer
by Deepak Vohra05/11/2005
A password is not required for the root user. To log in to the database with a password, specify the command:
>mysql -u root -p
test
database, an example database instance, with the command: >use test
test
database. The example table, Catalog
, is composed of ONJava articles. The SQL script to create the example table is listed below: CREATE TABLE Catalog(CatalogId INTEGER, Journal VARCHAR(25),
Publisher Varchar(25),
Date VARCHAR(25), Title Varchar(45), Author Varchar(25));
INSERT INTO Catalog VALUES('1', 'onjava',
'OReilly', 'April 2005', 'Five Favorite Features from 5.0',
'David Flanagan');
INSERT INTO Catalog VALUES('2', 'onjava',
'OReilly', 'Feb 2005', 'Introducing JBoss Remoting',
'John Mazzitelli');
INSERT INTO Catalog VALUES('3', 'onjava',
'OReilly', 'March 2005', 'ASPect-Oriented Annotations',
'Bill Burke');
Configuring SQLExplorer
Having installed the SQLExplorer plugin, we shall configure the SQLExplorer plugin in the Eclipse 3.01 IDE. First, set the SQLExplorer perspective in the Eclipse IDE. Click on the "Open a perspective" button in the Eclipse IDE to open a perspective. Figure 1 illustrates the "Open a perspective" button.
Figure 1. Opening a perspective
In the item list, select "Other..." to display the SQLExplorer plugin as shown in Figure 2.
Figure 2. The "Other..." perspective menu item
In the Select Perspective frame, select the SQLExplorer perspective, as shown in Figure 3. By selecting the SQLExplorer perspective, the SQLExplorer plugin features become available in the Eclipse IDE.
Figure 3. SQLExplorer perspective
Selecting the SQLExplorer perspective displays the features of the SQLExplorer plugin in Eclipse. The Drivers tab displays the different database drivers that may be used to connect to different databases. The available databases include DB2, MySQL, Oracle, Sybase, HSQLDB, SQL Server, and PostgreSQL. We shall configure the SQLExplorer with the MySQL database. To configure the MySQL driver, right-click on the MMMySQL Driver node and select Change the Selected Driver, as illustrated in Figure 4.
Figure 4. Modifying the Driver
In the Modify Driver frame, select the Extra Class Path tab and click on the Add button to add the MySQL driver .jar file (which you downloaded as part of Connector/J) to the classpath. Figure 5 illustrates adding the MySQL JDBC driver to the Eclipse classpath.
Figure 5. Setting the driver
Add the MySQL Connector/J driver .jar file, mysql-connector-java-3.0.16-ga-bin.jar, to the classpath. In the Example URL field, specify the connection URL to connect to the database. A JDBC connection will be created with the test
database, which is preconfigured in the MySQL install. The connection URL for the test
database is jdbc:mysql://localhost/test
. In the Driver Class Name field, specify the MYSQL JDBC driver as com.mysql.jdbc.Driver
. The MMMySQL driver gets configured with the settings shown in Figure 6.
Figure 6. Setting the MySQL JDBC settings
A connection alias is required to connect to the MySQL database and retrieve the database tables. A connection alias specifies the connection settings; JDBC driver, URL, username, and password. Select the Aliases tab in the SQLExplorer perspective. Click on the "Create new Alias" button to create a new Alias, as shown in Figure 7.
Figure 7. Create a new alias
In the "Create new Alias" frame, specify an alias name. Select the MMMySQL Driver to create a alias for the MySQL database. Specify the connection URL for the MySQL database test
, jdbc:mysql://localhost/test
, in the URL field. Figure 8 shows the MySQL alias settings.
Figure 8. Creating a new alias
This adds a MySQL alias to the Aliases tab frame, which is illustrated in Figure 9. To modify an alias, right-click on the alias node and select "Change the selected Alias."
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:JAVA规则——开发篇
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash