第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

初學(xué)hibernate框架,看視頻半小時(shí)以為會(huì)了,排錯(cuò)一天了都沒(méi)有結(jié)果,求指點(diǎn)?。?!

參照視頻寫(xiě)完配置文件,映射文件,持久類(lèi),還有數(shù)據(jù)庫(kù)表之后想小試牛刀,點(diǎn)Test方法運(yùn)行為JUNIT的頻繁出錯(cuò),到處碰壁呀,求救求指點(diǎn)!?。〕志妙?lèi):package?po; import?java.io.Serializable; public?class?User?implements?Serializable?{ private?static?final?long?serialVersionUID?=?1L; private?String?userName; public?User(){ } public?User(int?i){ } public?String?getUserName()?{ return?userName; } public?void?setUserName(String?userName)?{ this.userName?=?userName; } }配置文件:<?xml?version="1.0"?encoding="UTF-8"?> <!DOCTYPE?hibernate-configuration?PUBLIC "-//Hibernate/Hibernate?Configuration?DTD?3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!--?數(shù)據(jù)庫(kù)連接?--> <property?name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property?name="connection.url">jdbc.oracle.thin:@localhost:1521:orcl<!--?:///hibernate?useUnicode=trup&amp;characterEncoding=UTF-8?--></property> <property?name="connection.username">MKADMIN</property> <property?name="connection.password">MK123456</property> <!--?輔助參數(shù)?--> <property?name="dialect">org.hibernate.dialect.Oracle10gDialect</property> <property?name="show_sql">true</property> <property?name="format_sql">true</property> <property?name="htm2ddl.auto">create</property><!--?DDL語(yǔ)句生成策略?--> <property?name="current_session_context_class">true</property> <!--?映射文件?--> <mapping?resource="User.hbm.xml"?/> </session-factory> </hibernate-configuration>映射文件:<?xml?version="1.0"?encoding="UTF-8"?> <!DOCTYPE?hibernate-mapping?PUBLIC? ????"-//Hibernate/Hibernate?Mapping?DTD?3.0//EN" ????"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="po.User"?table="users"> <id?name="userName"?type="java.lang.String"> <column?name="username"?length="10"?/> </id> </class> </hibernate-mapping>測(cè)試類(lèi):import?org.hibernate.Session; import?org.hibernate.SessionFactory; import?org.hibernate.Transaction; import?org.hibernate.cfg.Configuration; import?org.hibernate.service.ServiceRegistry; import?org.hibernate.service.ServiceRegistryBuilder; import?org.junit.After; import?org.junit.Before; import?org.junit.Test; import?po.User; public?class?UserTest?{ private?SessionFactory?sf=null; private?Session?session=null; private?Transaction?tran=null; @Before public?void?init(){ //創(chuàng)建配置對(duì)象 Configuration?cfg=new?Configuration().configure(); //創(chuàng)建注冊(cè)服務(wù)對(duì)象 ServiceRegistry?serviceRegistry=new?ServiceRegistryBuilder().applySettings(cfg.getProperties()).buildServiceRegistry(); //創(chuàng)建工廠對(duì)象 sf=cfg.buildSessionFactory(serviceRegistry); //創(chuàng)建會(huì)話對(duì)象 session=sf.getCurrentSession(); //開(kāi)啟事務(wù) tran=session.beginTransaction(); } @After public?void?destroy(){ //釋放資源之前需先提交事務(wù) tran.commit(); session.close(); sf.close(); } @Test public?void?userTest(){ //生成用戶對(duì)象 User?su=new?User(); su.setUserName("zhangsanfeng"); session.save(su); } }數(shù)據(jù)庫(kù)SQL語(yǔ)句-- Create tablecreate table USERS(? username VARCHAR2(10) not null?constraint PK_USERS primary key)控制臺(tái)信息:2017-5-3 18:51:04 org.hibernate.annotations.common.Version <clinit>INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}2017-5-3 18:51:04 org.hibernate.Version logVersionINFO: HHH000412: Hibernate Core {4.2.4.Final}2017-5-3 18:51:04 org.hibernate.cfg.Environment <clinit>INFO: HHH000206: hibernate.properties not found2017-5-3 18:51:04 org.hibernate.cfg.Environment buildBytecodeProviderINFO: HHH000021: Bytecode provider name : javassist2017-5-3 18:51:04 org.hibernate.cfg.Configuration configureINFO: HHH000043: Configuring from resource: /hibernate.cfg.xml2017-5-3 18:51:04 org.hibernate.cfg.Configuration getConfigurationInputStreamINFO: HHH000040: Configuration resource: /hibernate.cfg.xml2017-5-3 18:51:04 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntityWARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!2017-5-3 18:51:04 org.hibernate.cfg.Configuration addResourceINFO: HHH000221: Reading mappings from resource: User.hbm.xml2017-5-3 18:51:04 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntityWARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!2017-5-3 18:51:04 org.hibernate.cfg.Configuration doConfigureINFO: HHH000041: Configured SessionFactory: null2017-5-3 18:51:04 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configureINFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)2017-5-3 18:51:04 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configureINFO: HHH000115: Hibernate connection pool size: 202017-5-3 18:51:04 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configureINFO: HHH000006: Autocommit mode: false2017-5-3 18:51:04 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configureINFO: HHH000401: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc.oracle.thin:@localhost:1521:orcl]2017-5-3 18:51:04 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configureINFO: HHH000046: Connection properties: {user=MKADMIN, password=****}JUNIT 錯(cuò)誤信息:java.lang.NullPointerException at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:214) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1818) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1776) at UserTest.init(UserTest.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
查看完整描述

1 回答

?
噼喱啪啦

TA貢獻(xiàn)392條經(jīng)驗(yàn) 獲得超170個(gè)贊

你先測(cè)試下JDBC是否連接正常

我看了你的目錄,驅(qū)動(dòng)文件是MySQL

而核心配置文件內(nèi),驅(qū)動(dòng)名卻是oracle

查看完整回答
反對(duì) 回復(fù) 2017-05-03
  • 迷失代碼林
    迷失代碼林
    oracle有驅(qū)動(dòng)的,名字是ojdbc14,網(wǎng)上下來(lái)就這樣 沒(méi)改過(guò)來(lái)不好意思
  • 1 回答
  • 0 關(guān)注
  • 1503 瀏覽
慕課專(zhuān)欄
更多

添加回答

了解更多

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)