de.julielab.xmlData.dataBase.QueryHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jedis Show documentation
Show all versions of jedis Show documentation
A utility for managing documents stored in a PostgreSQL database. The documents are imported into a PostgreSQL DB as full texts with the goal to be able to retrieve the documents by their PubMedID efficiently. For more sophisticated tasks, a user configuration file can be delivered which can take control of the table schema to use, the PostgreSQL schema to use and the actual database server to connect to as well as the concrete database.
The newest version!
package de.julielab.xmlData.dataBase;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class QueryHelper {
/**
* Returns the result of a query that returns a single count
*
* @param conn
* @param query
* @return
* @throws SQLException
*/
public static long getCount(Connection conn, String query) throws SQLException {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
if (rs.next())
return rs.getLong(1);
return -1;
}
}