Code: Select all
Mar 04, 2016 11:16:57 AM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@4629104a: startup date [Fri Mar 04 11:16:57 EST 2016]; root of context hierarchy
Mar 04, 2016 11:16:57 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring.xml]
Mar 04, 2016 11:16:57 AM org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
INFO: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
Mar 04, 2016 11:16:57 AM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
Mar 04, 2016 11:16:57 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
Mar 04, 2016 11:16:57 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.6.Final}
Mar 04, 2016 11:16:57 AM org.hibernate.cfg.Environment
INFO: HHH000206: hibernate.properties not found
Mar 04, 2016 11:16:57 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Mar 04, 2016 11:16:58 AM org.hibernate.dialect.Dialect
INFO: HHH000400: Using dialect: org.hibernate.dialect.SQLServer2012Dialect
Mar 04, 2016 11:16:58 AM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
Mar 04, 2016 11:16:58 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory
INFO: HHH000397: Using ASTQueryTranslatorFactory
Employee SignUp 1
e1
Employee SignUp 2
Employee SignUp 3
Employee SignUp 4
Mar 04, 2016 11:16:59 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 208, SQLState: S0002
Mar 04, 2016 11:16:59 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: Invalid object name 'Employee'.
Mar 04, 2016 11:16:59 AM org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl release
INFO: HHH000010: On release of batch it still contained JDBC statements
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute statement
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:211)
at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:62)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3124)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3581)
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:104)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:349)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1222)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
at org.rajan.csci7795.service.EmployeeService.signUpEmployee(EmployeeService.java:55)
at org.rajan.csci7795.model.EmployeeDB.main(EmployeeDB.java:18)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'Employee'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:390)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:308)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
... 14 more
Meine Mitarbeiterklasse
Code: Select all
package org.rajan.csci7795.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="Employee")
public class Employee {
@Id
@Column(name="E_id")
private String Employee_id;
@Column(name="Password")
private String Password;
@Column(name="First_Name")
private String first_name;
@Column(name="Last_Name")
private String last_name;
@Column(name="Email")
private String Email;
@Column(name="Phone")
private String phone;
public String getEmployee_id() {
return Employee_id;
}
public void setEmployee_id(String employee_id) {
Employee_id = employee_id;
}
public String getPassword() {
return Password;
}
public void setPassword(String password) {
Password = password;
}
public String getFirst_name() {
return first_name;
}
public void setFirst_name(String first_name) {
this.first_name = first_name;
}
public String getLast_name() {
return last_name;
}
public void setLast_name(String last_name) {
this.last_name = last_name;
}
public String getEmail() {
return Email;
}
public void setEmail(String email) {
Email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
Meine EmployeeSample-Klasse
Code: Select all
package org.rajan.csci7795.model;
import org.rajan.csci7795.service.EmployeeService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class EmployeeSample {
public static void main(String[] args) throws ClassNotFoundException {
ApplicationContext appContext = new ClassPathXmlApplicationContext("spring.xml");
EmployeeService src = appContext.getBean("employeeService",EmployeeService.class);
src.signUpEmployee();
}
Meine EmployeeService-Klasse
Code: Select all
package org.rajan.csci7795.service;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.rajan.csci7795.model.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
@Component
public class EmployeeService{
@Autowired
private SessionFactory sessionFactory;
private String Employee_id;
private String Password;
private String first_name;
private String last_name;
private String Email;
private String phone;
public void signUpEmployee()
{
System.out.println("Employee SignUp 1");
Employee employee= new Employee();
employee.setEmployee_id("e1");
employee.setPassword("rajan");
employee.setFirst_name("Rajan");
employee.setLast_name("Patel");
employee.setEmail("[email protected]");
employee.setPhone("y016801218");
System.out.println(employee.getEmployee_id());
System.out.println("Employee SignUp 2");
sessionFactory=getSessionFactory();
Session session=sessionFactory.openSession();
session.beginTransaction();
System.out.println("Employee SignUp 3");
session.save(employee);
System.out.println("Employee SignUp 4");
session.getTransaction().commit();
System.out.println("Employee SignUp 5");
session.flush();
session.close();
System.out.println("Employee SignUp");
}
public SessionFactory getSessionFactory() {
return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
}
Code: Select all
org.hibernate.dialect.SQLServer2012Dialect
false
create
org.hibernate.cache.internal.NoCacheProvider
Code: Select all
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
org.rajan.csci7795
mobileshop
war
0.0.1-SNAPSHOT
mobileshop Maven Webapp
http://maven.apache.org
org.glassfish.jersey.bundles
jaxrs-ri
2.16
org.glassfish.jersey.media
jersey-media-moxy
2.16
org.hibernate
hibernate-core
4.3.6.Final
org.hibernate
hibernate-entitymanager
4.3.2.Final
org.hibernate
hibernate-annotations
3.5.0-Final
javax.transaction
jta
1.1
mysql
mysql-connector-java
5.1.31
org.springframework
spring-web
4.1.4.RELEASE
org.springframework
spring-jdbc
4.1.4.RELEASE
org.springframework
spring-core
4.1.4.RELEASE
org.springframework
spring-orm
4.0.8.RELEASE
javax.validation
validation-api
1.0.0.GA
mobileshop
org.apache.maven.plugins
maven-compiler-plugin
2.5.1
true
1.7
1.7
Mobile version