Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从MySql数据库加载UUID_Java_Mysql_Uuid - Fatal编程技术网

Java 从MySql数据库加载UUID

Java 从MySql数据库加载UUID,java,mysql,uuid,Java,Mysql,Uuid,我有一个数据库,我使用UUID作为主键。我使用java将UUID存储为二进制文件(16)。要保存条目,我使用以下命令 public boolean saveEntry(UUID id , String, name, int p1, int p2) throws SQLException { byte[] uuidBytes = new byte[16]; ByteBuffer.wrap(uuidBytes).order(ByteOrder.BIG_ENDIAN).putLong(

我有一个数据库,我使用UUID作为主键。我使用java将UUID存储为二进制文件(16)。要保存条目,我使用以下命令

public boolean saveEntry(UUID id , String, name, int p1, int p2) throws SQLException
{
    byte[] uuidBytes = new byte[16];
    ByteBuffer.wrap(uuidBytes).order(ByteOrder.BIG_ENDIAN).putLong(id.getMostSignificantBits())
            .putLong(id.getLeastSignificantBits());
    String updateQuery = "INSERT INTO " + databaseTableName + " (ID, Name, p1, p2) "
            + "VALUES " + "(?, ?, ?, ?) "
    PreparedStatement statement = null;
        // write the id in the workflow table
        statement = databaseConnection.prepareStatement(updateQuery);
        statement.setBytes(1, uuidBytes);
        statement.setString(2, name);
        statement.setInt(3, p1);
        statement.setInt(4, p2);
        statement.execute();
这部分正在工作,我可以在数据库中看到我的条目

但是,当我尝试加载带有以下内容的条目时:

public Workflow loadEntry(UUID id) throws SQLException
{
    byte[] uuidBytes = new byte[16];
    ByteBuffer.wrap(uuidBytes).order(ByteOrder.BIG_ENDIAN).putLong(id.getMostSignificantBits())
            .putLong(id.getLeastSignificantBits());
    String query = "SELECT " + "* " + "FROM " + databaseTableName + " WHERE " + databaseTableName
            + ".ID = ?";
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;
    try
    {
        preparedStatement = databaseConnection.prepareStatement(query);
        preparedStatement.setBytes(1, uuidBytes);
        resultSet = preparedStatement.executeQuery(query);
我犯了以下错误:

您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 在第1行的“?”附近


我不太清楚错误的原因是什么。我知道使用
id.toString()。那么有什么办法可以绕过这个解决方案吗?

实际表中
ID
列的类型是什么?binary(16)@TimBiegeleisen实际表中
ID
列的类型是什么?binary(16)@TimBiegeleisen