Bunch of Errors after I run my Code

I was trying to add a User in my database using Java with Spring framework(Standalone) but I have encountered problems specifically in this code

package test;
import dao.FinanceDao;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
public class TestDrive {

    public static void main(String[] args){

        FinanceDao finance = new FinanceDao();
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://localhost:3306/payroll");
        dataSource.setUsername("root");
        dataSource.setPassword("123192");

        finance.setDataSource(dataSource);

        finance.Add("2010-01015", "51010");

    }
}

and after I ran it I have encountered these errors

Nov 30, 2011 12:40:14 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
Nov 30, 2011 12:40:15 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
Nov 30, 2011 12:40:15 PM org.springframework.jdbc.support.SQLErrorCodesFactory <init>
INFO: SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO PERSON (empID,password) VALUES(?,?)]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'empID' in 'field list'
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:230)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:553)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:738)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:796)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:804)
    at dao.FinanceDao.Add(FinanceDao.java:24)
    at test.TestDrive.main(TestDrive.java:17)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'empID' in 'field list'
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.Util.getInstance(Util.java:386)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2427)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2345)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2330)
    at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:744)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:537)
    ... 5 more

if it would help this is my FinanceDao code

package dao;

import javax.sql.DataSource;
import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;

import dao.mapper.UserRowMapper;
import domainmodel.User;

public class FinanceDao implements Manage {

    private DataSource ds;

    @Override
    public void setDataSource(DataSource ds) {
        this.ds = ds;

    }

    @Override
    public void Add(String empID, String password) {
        JdbcTemplate Add = new JdbcTemplate(ds);
        Add.update("INSERT INTO PERSON (empID,password) VALUES(?,?)",
        new Object[] { empID, password });
    }

    @Override
    public void Delete(String empID , String password) {
        JdbcTemplate Delete = new JdbcTemplate(ds);
        Delete.update("Delete from User where emp_id = '?'",new Object[]{empID});
    }

}

Answers


I see an exception Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'empID' in 'field list', are you sure the column is called empID and not empId or something similar?


Need Your Help

Create NSScrollView Programatically in an NSView - Cocoa

objective-c cocoa nsscrollview

I have an NSView class which takes care of a Custom View created in the nib file.

Static Initialization

java instance-variables static-initialization

I'm running into a problem when I compile my code. When I compile my code foo2.var returns null in class foo and I can't seem to figure out why. Is there something wrong in how I'm doing the static

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.