0
データベースに行を更新するためにJDBC接続を使用するOSGIバンドルに取り組んでいます。これは、ソースコードである:JDBC - getConnection()が見つかりません
package org.DX_57.osgi.SH_27.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.activation.DataSource;
import javax.annotation.Resource;
import org.DX_57.osgi.SH_27.api.SessionHandle;
public class SessionHandleImpl implements SessionHandle {
@Resource(name="jdbc/Oracle") DataSource ds;
@Override
public String sayHello(String name) {
return "test2 " + name;
}
@Override
public String CheckUserDB(String userToCheck) {
String storedPassword = null;
String error_Message = null;
String SQL_Statement = null;
String error_Database = null;
Connection conn = ds.getConnection();
if (conn == null) throw new SQLException(error_Database = "No connection");
try {
conn.setAutoCommit(false);
boolean committed = false;
try {
SQL_Statement = "SELECT Passwd from USERS WHERE Username = ?";
PreparedStatement passwordQuery = conn.prepareStatement(SQL_Statement);
passwordQuery.setString(1, userToCheck);
ResultSet result = passwordQuery.executeQuery();
if(result.next()){
storedPassword = result.getString("Passwd");
}
conn.commit();
committed = true;
} finally {
if (!committed) conn.rollback();
}
} finally {
conn.close();
}
/** if the user is not found or password don't match display error message*/
if (storedPassword == null) {
error_Message = "Invalid Username!";
} else {
error_Message = "Invalid Password!";
}
return storedPassword;
}
}
私は、このエラーメッセージが表示されますバンドルをコンパイルしようとすると:
これは、NetBeansからのエラー・スタックである:getConnection()
が見つからないことを思わhttp://pastebin.com/zDpy8RpL
?私はどのように問題を解決できるか知っていますか?
import javax.sql.DataSource;
:
import javax.activation.DataSource;
正しいものを持つjavax.sqlからDatasourceです:
賭けは