Re: ERROR 1193 (HY000): Unknown system variable
Posted by: Macamba .
Date: August 08, 2015 05:42AM

Oeps, wrong code.

public void update(Project project) throws IllegalArgumentException, DAOException {
	if (project.getProjectId() == 0) {
		throw new IllegalArgumentException("project is not created yet, the project ID is null.");
	}
		
	Object[] values = { 
			project.getPerNumber(),
			project.getProjectName(),  
			project.getActivity(),
			project.getPerNumber(), 
			toSqlDate(project.getDate()), 
			project.getTime(), 
			project.getProjectId() };
		
	System.out.println("ProjectDAOImplementation: update(): " +
			  "pro_id=" + project.getProjectId() +
			", projectnumber=" + project.getPerNumber() +
			", projectName=" + project.getProjectName() + 
			", activity=" + project.getActivity() +
			", personnel number=" + project.getPerNumber() +
			", day=" + project.getDate() +
			", worked_time=" + project.getTime() +
			", project ID=" + project.getProjectId() +".");
	System.out.println (SQL_UPDATE);
		
	try (Connection connection = daoFactory.getConnection();
			PreparedStatement statement = prepareStatement(connection, SQL_UPDATE, false, values);) {
		int affectedRows = statement.executeUpdate();
		if (affectedRows == 0) {
			throw new DAOException("Updating project failed, no rows affected.");
		}
	} catch (SQLException e) {
		throw new DAOException(e);
	}
}

So, with the rest of the text copied:
The prepared statement is:
private static final String SQL_UPDATE = "SET projectnumber=?, project=?, activity=?, " + 
	" per_number=?, day=?, worked_time=? FROM projects WHERE pro_id=?";

And this is the code from above portion of code:
ProjectDAOImplementation: update(): 
	pro_id=2, 
	projectnumber=100101, 
	projectName=TimeKeeper, 
	activity=DAOTest, 
	personnel number=100101, 
	day=2015-04-10, 
	worked_time=04:15:00, 
	project ID=2.
	
SET projectnumber=?, project=?, activity=?,  per_number=?, day=?, worked_time=? 
FROM projects 
WHERE pro_id=?

class nl.pruttel.tk.dao.DAOException - java.sql.SQLException: 
	Unknown system variable 'projectnumber'
Exception in thread "main" java.lang.NullPointerException
	at nl.pruttel.tk.dao.DAOException.logState(DAOException.java:76)
	at nl.pruttel.tk.dao.DAOException.<init>(DAOException.java:51)
	at nl.pruttel.tk.dao.ProjectDAOImplementation.update(ProjectDAOImplementation.java:262)
	at nl.pruttel.tk.dao.DAOTest.main(DAOTest.java:88)

I used the output from my code to recreate the query in the MySQL console. The result I posted in my question. The result is the same (?)

Why is my column name 'projectnumber' an unknow system variable, as in https://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html. I'm scratching my head.

Options: ReplyQuote


Subject
Written By
Posted
Re: ERROR 1193 (HY000): Unknown system variable
August 08, 2015 05:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.