PostgreSQL with Java

package org.connect.jdbc;
import java.sql.*;

public class eksamenf {

	public static void main(String[] s) throws SQLException {
		String url, user, pass, ps;
		url = "jdbc:postgresql://erlend.*****.com/postgres";
		user = "postgres";
		pass = "*****";

		Connection db = DriverManager.getConnection(url, user, pass);
		TimerMinutter svar = finnTotalTid(10000,2009,db); 
		System.out.print("Total tid: " + svar.getTimer() + ":");
	public static TimerMinutter finnTotalTid(int ansattId, int aar, Connection c) throws SQLException {

		String sql ="select SUM(t.timer) as timer, SUM(t.minutter) as minutter " +
			"from timer t, ansatt a " +
			"where and"+ansattId+" and " +
			"dato BETWEEN '01.01."+aar+"' and '31.12."+aar+"' " +
			"group by;";
		PreparedStatement st = c.prepareStatement(sql);
		ResultSet r = st.executeQuery();

		TimerMinutter resultat = new TimerMinutter();
		while( {
	return resultat;		


No Responses Yet to “PostgreSQL with Java”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: