Tomcat をサーバーとして使用し、Derby をデータベースとして使用しているときに、ルックアップを行い、次のようなクエリを実行しました。
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/PollDatasource");
Connection connection = ds.getConnection();
// write the query that tells the current weight of actor
String currentWeightQuery = "SELECT " + justPolled + ",total FROM pollresult";
PreparedStatement currentWeight = connection.prepareStatement(currentWeightQuery);
ResultSet cwSet = currentWeight.executeQuery();
現在、Microsoft SQL Server 2005を使用しており、Java デスクトップ アプリケーションからデータベースにクエリを実行する必要があります。SQL Server 2005 にクエリを実行するには何が必要ですか? 既に sqlserver-jdbc ドライバーをロードしてデータベースに接続していますが、データベースからデータを取得する方法がわかりません。