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

Todd Farmer Wrote:
-------------------------------------------------------
> Hi Macamba,
>
> I'm a little confused about what this statement
> aims to do - can you clarify?

Hi Todd,

Thanks for taking the time to delve into my problem. I'm still programming with my training wheels on my bike.

This is the code I'm trying to run:
public void create(Project project) throws IllegalArgumentException, DAOException {
	if (project.getProjectId() != 0) {
		throw new IllegalArgumentException("Project is already created, the project ID is not null.");
	}

	Object[] values = { project.getProjectNumber(), project.getProjectName(), 
			project.getActivity(), project.getPerNumber(),
			toSqlDate(project.getDate()), project.getTime()}; 

	System.out.println ("Data:  projectNumber=" + project.getProjectNumber() +
			", project=" + project.getProjectName() +
			", activity=" + project.getActivity() +
			", perNumber=" + project.getPerNumber() +
			", day=" + project.getDate() +
			", worked_time=" + project.getTime() );
	System.out.println ("Query: " + SQL_INSERT_PROJECT);
		
	try (Connection connection = daoFactory.getConnection();
		PreparedStatement statement = prepareStatement(connection, SQL_INSERT_PROJECT, 
				true, values);) {
		int affectedRows = statement.executeUpdate();
		if (affectedRows == 0) {
			throw new DAOException("Creating user failed, no rows affected.");
		}
		try (ResultSet generatedKeys = statement.getGeneratedKeys()) {
			if (generatedKeys.next()) {
				project.setProjectId(generatedKeys.getLong(1));
			} else {
				throw new DAOException("Creating user failed, no generated key obtained.");
			}
		}
	} catch (SQLException e) {
		throw new DAOException(e);
	}
}

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:27AM


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.