2 qq 29052403 qq_29052403 于 2016.01.27 20:37 提问

求高手帮助我,急!如下所示!

我的oracle版本号如图:
图片说明
myeclipse2014,hibernate jar包图片说明
hibernate configure
<?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">

<session-factory>
    <property name="connection.username">scott</property>
    <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
    <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
    <property name="myeclipse.connection.profile">oracle</property>
    <property name="connection.password">123123</property>
    <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="show_sql">true</property>

    <!-- <mapping resource="entity/User.hbm.xml"/>  -->
    <mapping resource="entity/Abc.hbm.xml"/>

</session-factory>


实体
package entity;

import java.io.Serializable;
import java.util.List;

public class Abc{
private int id;
private String uname;
private int age;
private char sex;
private String password;
private String headimg;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getHeadimg() {
return headimg;
}
public void setHeadimg(String headimg) {
this.headimg = headimg;
}

public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public char getSex() {
return sex;
}
public void setSex(char sex) {
this.sex = sex;
}
public Abc() {
super();
}
}
映射
<?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" >

<class name="entity.User" table="t_user">
    <id name="id" column="u_id">
        <generator class="sequence">
            <param name="sequence">SQL_MARY</param>
        </generator>
    </id>
    <property name="uname" column="u_name" type="java.lang.String" />
    <property name="age" column="u_age" />
    <property name="sex" column="u_sex" />
    <property name="password" column="u_password" />
    <property name="headimg" column="head" />
</class>


测试类
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import entity.Abc;

public class test {
public static void main(String args[])
{
Configuration cfg=new Configuration();
cfg.configure();
SessionFactory sf=cfg.buildSessionFactory();
Session s=sf.openSession();
Abc a=new Abc();
a.setUname("xxk");
a.setAge(21);
a.setHeadimg("1.jpg");
a.setPassword("1213564");
a.setSex('男');
try
{
s.getTransaction().begin();
s.save(a);
s.getTransaction().commit();
}catch(Exception e)
{
e.printStackTrace();
s.getTransaction().rollback();
}
if(s!=null)
{
s.close();
}
}
}
异常
图片说明
一月 27, 2016 8:04:59 下午 org.hibernate.annotations.common.reflection.java.JavaReflectionManager
INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
一月 27, 2016 8:04:59 下午 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.1.Final}
一月 27, 2016 8:04:59 下午 org.hibernate.cfg.Environment
INFO: HHH000206: hibernate.properties not found
一月 27, 2016 8:04:59 下午 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
一月 27, 2016 8:04:59 下午 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
一月 27, 2016 8:04:59 下午 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
一月 27, 2016 8:04:59 下午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
一月 27, 2016 8:04:59 下午 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: entity/Abc.hbm.xml
一月 27, 2016 8:04:59 下午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
一月 27, 2016 8:04:59 下午 org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
一月 27, 2016 8:05:00 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
一月 27, 2016 8:05:00 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000401: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:@localhost:1521:orcl]
一月 27, 2016 8:05:00 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000046: Connection properties: {user=scott, password=****}
一月 27, 2016 8:05:00 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
一月 27, 2016 8:05:00 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator$1$1.convert(BasicConnectionCreator.java:122)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:140)
at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:58)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:75)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:106)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
at test.main(test.java:13)
Caused by: java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:439)
at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:55)
... 14 more

5个回答

caozhy
caozhy   Ds   Rxr 2016.01.27 21:09

别的也不用贴了,错误信息很清楚,jdbc驱动问题,检查你的驱动jar包和连接字符串,以及你的数据库服务器的配置。

enpterexpress
enpterexpress   Rxr 2016.01.27 22:00
qq_34810008
qq_34810008   2016.04.27 14:17

数据库配置信息是orcl吗 看是否与数据库匹配

qq_34810008
qq_34810008   2016.04.27 14:17

数据库配置信息是orcl吗 看是否与数据库匹配

qq_29052403
qq_29052403   2016.01.27 20:38

我的电脑是64位,oracle是32,PLSQL是32

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
永远记住那些在困难的时候真诚帮助过我的人
永远记住那些在困难的时候真诚帮助过我的人
毕业论文完成,感谢帮助过我的人
当我最终完成这篇论文的时候,我想起了所有关心、帮助、指导过我的老师、同学 和朋友们,在此向他们表示由衷的谢意! 感谢我的导师王伟教授。从跟随王老师做本科毕业设计、到硕士学习阶段、最后到 硕士毕业论文,王老师给我的帮助和影响是巨大的。他实干创新,在研究工作中培养我 们的专业风格,使我们终身受益;他言简意赅,但他的指点总能给我很大的启发;他不 苟言笑,但是可以感受到他总是在为学生着想。在硕士学业即将
10个工具让你的shell脚本更强大
转载自:http://www.csdn.net/article/2012-02-28/312483 很多人误以为shell脚本只能在命令行下使用。其实shell也可以调用一些GUI组件,例如菜单,警告框,进度条等等。你可以控制最终的输出,光标位置还有各种输出效果。下面我将介绍一些工具,帮助你创建强大的,互动的,用户友好的 Unix/Linux shell脚本。我在FreeBSD和
数据结构学习笔记(12)----平衡二叉排序树
定义: 左子树与右子树的高度之差的绝对值小于等于1 左右子树也是平衡二叉树 a.平衡因子定义: 节点的左子树与右子树的深度之差** 例如: 平衡树的平衡方法:(1)LL型 B = A->lchild; A->lchild = B->rchild; B->rchild = A; A->bf =
急急急!!!!!!!!!!帮助我拿下意见,不胜感激!
 
Javascript自定义菜单插件
前段时间用了差不多一个月的时间用Javascript编写了一个菜单插件,目前已经支持:   1. 菜单创建   2. 动态添加、修改和删除菜单项   3. 动态设定菜单项的图标   4. 动态更改菜单项的事件处理器   5. 指定菜单显示位置   6. 根据需要自定义菜单样式   经过测试,此插件已基本能够在IE 8+,chrome和firefox浏览器中正常运行。现附加效果图,如下
插件技术原理及其C#实现(一)插件技术原理及其特性
插件技术原理及其C#实现(一)插件技术原理及其特性 (原创不易,引用请注明作者、出处!) 插件是一种遵循统一的预定义接口规范编写出来的程序,应用程序在运行时通过接口规范对插件进行调用,以扩展应用程序的功能。插件在英文中通常称为plug-in、plugin或者plug in。插件最典型的例子是Microsoft的ActiveX控件和COM(Component Object Model,部件对
【算法导论】22.7 无向图的广度优先搜索--C++实现
这是用无向图的广度优先搜索代码,如果是有向图需要稍微修改,否则产生死循环。 邻接矩阵表示的无向图的广度优先搜索: #include #include #include using namespace std; #define N 6 #define INFINITE 0x7fffffff #define WHITE 1 #define GRAY 2 #define BLACK 3
vb动画(浪漫爱情)
初学者之作,望海涵,对于不足之处,请高手多多指教,帮助我提高自己的水平
急!!!!!!!!!!!!!求高手帮助
<br />最近在学习Struts2的过程中遇到个问题,例如有老师,学生,管理员三个人物,都可以进行提问,但是同时在你进行提问以后,需要对问题库进行更新,这个时候就会去调用Action中对问题的对应处理方法,但是对于老师,学生,和管理员中的提问方法要以接口的形式写出来。请问该怎么去写。  求高手指教啊!!!!!!!!!