Помогите мне решить эту проблему. Он не подключается к базе данных, и я использую сервер wamp в качестве базы данных
[Иерархия файлов] [1]
>
public boolean login() {
try{
SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory();
Session session=sessionFactory.openSession();
session.beginTransaction();
Query query=session.createQuery("from Login where username=:username and password=:password");
query.setString("username", username);
query.setString("password", password);
List list=query.list();
System.out.println("list size"+list.size());
if(list.size()==1){
return true;
}else{
return false;
}
}
catch(Exception e)
{
System.out.println(e);
}
return false;
}
Файл журнала, и я использую сервер Glass Fish
HHH000043: Configuring from resource: /hibernate.cfg.xml
Info: HHH000040: Configuration resource: /hibernate.cfg.xml
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!
Info: HHH000221: Reading mappings from resource: hibernate.hbm.xml
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!
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!
ERROR: HHH000196: Error parsing XML (2) : The content of element type "class" is incomplete, it must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,fetch-profile*,resultset*,(query|sql-query)*)".
Info: org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:109)
at org.hibernate.cfg.Configuration.add(Configuration.java:488)
Файл конфигурации Hiberanate: hibernate.config.xml
<?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>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jsfformdb</property>
<property name="hibernate.connection.username">root</property>
<!-- <property name="password" />
<property name="connection.pool_size">1</property> -->
<property name="hbm2ddl.auto">update</property>
<!--<mapping class="Login.Login"></mapping>-->
<mapping resource="hibernate.hbm.xml"/>
</session-factory>
</hibernate-configuration>
->
Файл отображения Hiberanet: hibernate.hbm.xml
<?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="Login.Login" table="login1"/>
</hibernate-mapping>