JFinal串連Oracle資料庫實戰

來源:互聯網
上載者:User

標籤:oracle   jfinal   

添加oracle驅動包:

在lib中添加ojdbc6.jar


在controller中配置外掛程式:

/** * 配置外掛程式 */public void configPlugin(Plugins me) {/*// 配置C3p0資料庫連接池外掛程式C3p0Plugin c3p0Plugin = new C3p0Plugin(getProperty("jdbcUrl"), getProperty("user"), getProperty("password").trim());me.add(c3p0Plugin);// 配置ActiveRecord外掛程式ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);me.add(arp);arp.addMapping("blog", Blog.class);// 映射blog 表到 Blog模型  預設是idarp.addMapping("em_messages_entities","uuid", EMMessagesEntities.class);// 映射em_messages_entities 表到 EMMessagesEntities模型arp.addMapping("em_messages_bodies","msg_id", EMMessagesBodies.class);// 映射em_messages_bodies 表到 EMMessagesBodies模型 msg_id為表的主鍵名arp.addMapping("em_user","username", EMUser.class);// 映射em_user 表到 UserUploadVideo模型   rowid為表的主鍵名arp.addMapping("upload_user_video","videoname", UserUploadVideo.class);// 映射upload_user_video 表到 UserUploadVideo模型 videoname為表的主鍵名*//*Oracle 配置*/C3p0Plugin cp = new C3p0Plugin(getProperty("jdbcUrl"), getProperty("user"), getProperty("password").trim());//配置Oracle驅動cp. setDriverClass("oracle.jdbc.driver.OracleDriver");me.add(cp);ActiveRecordPlugin arp = new ActiveRecordPlugin(cp);me.add(arp);// 配置Oracle方言arp.setDialect(new OracleDialect());// 配置屬性名稱(欄位名)大小寫不敏感容器工廠arp.setContainerFactory(new CaseInsensitiveContainerFactory());//arp.addMapping("user", "user_id", User.class);//arp.addMapping("EM_MESSAGES_ENTITIES","uuid", EMMessagesEntities.class);// 映射em_messages_entities 表到 EMMessagesEntities模型//arp.addMapping("EM_MESSAGES_BODIES","msg_id", EMMessagesBodies.class);// 映射em_messages_bodies 表到 EMMessagesBodies模型 msg_id為表的主鍵名arp.addMapping("EM_USER","username", EMUser.class);// 映射em_user 表到 UserUploadVideo模型   rowid為表的主鍵名//arp.addMapping("UPLOAD_USER_VIDEO","videoname", UserUploadVideo.class);// 映射upload_user_video 表到 UserUploadVideo模型 videoname為表的主鍵名}


設定檔:

jdbcUrl =jdbc:oracle:thin:@localhost:1521:jfinalemchat
user = SCOTT
password =123456789
devMode = true

註:其中:jfinalemchat為你的資料庫sid

右鍵-->屬性-->


"listener does not currently know of SID given in connect descriptor"異常:


先開啟listener.ora檔案:

F:\app\qianhua\product\11.2.0\dbhome_1\NETWORK\ADMIN


# listener.ora Network Configuration File: F:\app\qianhua\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.


SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = F:\app\qianhua\product\11.2.0\dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:F:\app\qianhua\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    )

(SID_DESC = 
(GLOBAL_DBNAME = jfinalemchat ) 
(ORACLE_HOME = F:\app\qianhua\product\11.2.0\dbhome_1)
(SID_NAME = jfinalemchat)
)
  )


LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
  )


ADR_BASE_LISTENER = F:\app\qianhua



附件資源:



帳號:
http://www.blogjava.net/wangdetian168/archive/2013/09/09/403858.html


下載:
http://www.oracle.com/technetwork/cn/database/enterprise-edition/downloads/112010-win32soft-098630-zhs.html


安裝說明:
http://www.jb51.net/article/32616.htm


使用說明:

資料庫使用詳解:[3]SQL Developer如何配置
http://jingyan.baidu.com/article/e4511cf33f289e2b845eafb6.html


建立新的資料庫:
http://jingyan.baidu.com/article/90bc8fc80c01f2f653640c1f.html


使用Oracle SQLDeveloper串連資料庫並建立使用者
http://blog.csdn.net/xw13106209/article/details/6594738


操作:
Oracle開啟cmd命令視窗 輸入 SQLPLUS USERNAME/[email protected]_NAME


SYS密碼:
如果忘記了,可以採用如下命令修改SYS密碼。
1.首先登陸本機伺服器
2.進入命令列
2.sqlplus / as sysdba
4.alter user sys identified by ‘輸入密碼‘。
http://blog.csdn.net/zzjjian333/article/details/8286341


許可權不足:
以SYS登入,然後執行:GRANT CREATE ANY TABLE TO SCOTT


瀏覽器開啟oracle操作介面:
https://主機名稱:1158/em


http://blog.csdn.net/wl_ldy/article/details/5920146

JFinal串連Oracle資料庫實戰

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.