线程“main”java.sql.SQLException中的异常:当我尝试将值设置为Procedure时,列索引无效

时间:2016-07-22 21:22:53

标签: java oracle jdbc plsql

我有一个如下程序,

    switch (event.sensor.getType())
    {
        case Sensor.TYPE_GRAVITY:
            sensorXLabel.setText(R.string.xAxisLabel);
            sensorXValue.setText(String.valueOf(event.values[0]));

            sensorYLabel.setText(R.string.yAxisLabel);
            sensorYValue.setText(String.valueOf(event.values[1]));

            sensorZLabel.setText(R.string.zAxisLabel);
            sensorZValue.setText(String.valueOf(event.values[2]));

            sensorYLabel.setVisibility(View.VISIBLE);
            sensorYValue.setVisibility(View.VISIBLE);
            sensorZLabel.setVisibility(View.VISIBLE);
            sensorZValue.setVisibility(View.VISIBLE);

            if (selectedSensorId == R.id.gravitySensor)
            {
                if (event.values[2] >= GRAVITY_THRESHOLD)
                {
                    onFaceUp();
                }
                else if (event.values[2] <= (GRAVITY_THRESHOLD * -1)) 
                {
                    onFaceDown();
                }
            }
            else
            {
                accelerationValues = event.values.clone();
                rotationMatrix = generateRotationMatrix();

                if (rotationMatrix != null)
                {
                    determineOrientation(rotationMatrix);
                }
            }

            break;
        case Sensor.TYPE_ACCELEROMETER:
            accelerationValues = event.values.clone();
            rotationMatrix = generateRotationMatrix();

            if (rotationMatrix != null)
            {
                determineOrientation(rotationMatrix);
            }
            break;
        case Sensor.TYPE_MAGNETIC_FIELD:
            magneticValues = event.values.clone();
            rotationMatrix = generateRotationMatrix();

            if (rotationMatrix != null)
            {
                determineOrientation(rotationMatrix);
            }
            break;
        case Sensor.TYPE_ROTATION_VECTOR:

            rotationMatrix = new float[16];
            SensorManager.getRotationMatrixFromVector(rotationMatrix,
                    event.values);
            determineOrientation(rotationMatrix);
            break;
    }
}

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy)
{
    Log.d(TAG,
            String.format("Accuracy for sensor %s = %d",
            sensor.getName(), accuracy));
}

/**
 * Generates a rotation matrix using the member data stored in
 * accelerationValues and magneticValues.
 * 
 * @return The rotation matrix returned from
 * {@link android.hardware.SensorManager#getRotationMatrix(float[], float[], float[], float[])}
 * or <code>null</code> if either <code>accelerationValues</code> or
 * <code>magneticValues</code> is null.
 */
private float[] generateRotationMatrix()
{
    float[] rotationMatrix = null;

    if (accelerationValues != null && magneticValues != null)
    {
        rotationMatrix = new float[16];
        boolean rotationMatrixGenerated;
        rotationMatrixGenerated =
                SensorManager.getRotationMatrix(rotationMatrix,
                null,
                accelerationValues,
                magneticValues);

        if (!rotationMatrixGenerated)
        {
            Log.w(TAG, getString(R.string.rotationMatrixGenFailureMessage));

            rotationMatrix = null;
        }
    }

    return rotationMatrix;
}

/**
 * Uses the last read accelerometer and gravity values to determine if the
 * device is face up or face down.
 * 
 * @param rotationMatrix The rotation matrix to use if the orientation 
 * calculation
 */
private void determineOrientation(float[] rotationMatrix)
{
    float[] orientationValues = new float[3];
    SensorManager.getOrientation(rotationMatrix, orientationValues);

    double azimuth = Math.toDegrees(orientationValues[0]);
    double pitch = Math.toDegrees(orientationValues[1]);
    double roll = Math.toDegrees(orientationValues[2]);

    sensorXLabel.setText(R.string.azimuthLabel);
    sensorXValue.setText(String.valueOf(azimuth));

    sensorYLabel.setText(R.string.pitchLabel);
    sensorYValue.setText(String.valueOf(pitch));

    sensorZLabel.setText(R.string.rollLabel);
    sensorZValue.setText(String.valueOf(roll));

    sensorYLabel.setVisibility(View.VISIBLE);
    sensorYValue.setVisibility(View.VISIBLE);
    sensorZLabel.setVisibility(View.VISIBLE);
    sensorZValue.setVisibility(View.VISIBLE);

    if (pitch <= 10)
    {   
        if (Math.abs(roll) >= 170)
        {
            onFaceDown();
        }
        else if (Math.abs(roll) <= 10)
        {
            onFaceUp();
        }
    }
}

当我尝试为 create or replace procedure insertemployee3( p_eno employee2.eno%type, p_ename employee2.ename%type, p_eadd employee2.eadd%type, p_ecmpy employee2.ecmpy%type) is begin insert into employee2 (eno,ename, eadd, ecmpy) values (111,p_ename,'HYD',p_ecmpy); commit; end; p_ename, p_ecmpy对象设置值时,我正在

PrepareStatement

这是我的Java代码:

Exception in thread "main" java.sql.SQLException: Invalid column index.    

在上面的代码中,我正在尝试为Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:xe","system","manager"); CallableStatement stmt=con.prepareCall("{call insertemployee3(?,?)}"); stmt.setString(2,"Amit"); stmt.setString(4,"Accenture"); stmt.execute(); System.out.println("success"); 设置值。

请帮我摆脱这个例外。

0 个答案:

没有答案