1,首先去ORACLE下載一個oracle-xe-universal_10.2.0.1-1.0_i386.ded,要註冊,是免費的。
2,下載完成後,打開終端進入到文件下載的目錄裏,(CD進入)
3,然後執行 sudo dpkg -i oracle-xe-universal_10.2.0.1-1.0_i386.deb,自動安裝。
4,安裝直至出現一句You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
時,轉換用戶,輸入su,跟住輸入你的root密碼。
5,進入了root用戶終端後,執行/etc/init.d/oracle-xe configure
6,分別設置如下:
the HTTP port that will be used for oracle Application Express:8080
the port that will be used for the database listener:1521
the password to be used for database accounts:你的管理員和超級用戶密碼。
跟住輸入y繼續。
7,經過一小段時間後,提示To access the Database Home Page go to "http://127.0.0.1:8080/apex",打開瀏覽器輸入http://127.0.0.1:8080/apex看看發生了什麼事!呵呵...........
首先要添加一個新的庫,導入jar文件。在目錄/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/jdbc/lib下有兩個jar文件。導入。
再在netbeans左邊欄是選中庫的,添加你新建的庫就可以了。
/**
*連接數據庫存
*
*/
package com.s2.dao;
import java.sql.Connection;
import java.sql.DriverManager;
public class ConnMySql
{
public ConnMySql() {}
public static Connection ConnDB()
{
Connection conn = null;
try
{
//oracle的連接方法,運行裏要先加入庫文件即JDBC驅動
//Class.forName("oracle.jdbc.driver.OracleDriver");
//conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521","SYSTEM","SYSTEM");
System.out.println("連接MYSQL成功!");
}
catch(Exception e)
{
e.printStackTrace();
}
return conn;
}
//關閉連接
public static void CloseDB(Connection conn)
{
try
{
if(!conn.isClosed())
{
conn.close();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] arge)
{
ConnMySql connmysql = new ConnMySql();
connmysql.ConnDB();
}
}
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=981908