Обсуждение: JDBC polling data sources: what's i did wrong?

Поиск
Список
Период
Сортировка

JDBC polling data sources: what's i did wrong?

От
"Serg N Elin"
Дата:
Hi there,

here is a simple application which i wrote for testing purposes:

...

 Jdbc3PoolingDataSource source = new Jdbc3PoolingDataSource();
 source.setServerName("localhost");
 source.setDatabaseName("cruz");
 source.setUser("cruz");
 source.setPassword(null);
 source.setMaxConnections(5);

      Connection conn = source.getConnection();

      PreparedStatement st = conn.prepareStatement(
          "INSERT INTO test (from_addr, "
          + " to_addr, subject, body, received, message_id,in_reply_to)
values (?,?,?,?,?,?,?)"
          );
      st.setString(1, "test");
      st.setString(2, "test");
      st.setString(3, "test");
      st.setString(4, "test");
      st.setDate(5, new java.sql.Date(new Date().getTime()));
      st.setString(6,"test");
       st.setString(7,"test");

      int count = st.executeUpdate();

      st.close();

      conn.close();
    }
    catch (SQLException ex) {
      ex.printStackTrace();
    }
then code executed there are no any data that you can seen in example in the
table/// So the qestion is what's i'm doing wrong?

jdk 1.4.1_01, PostgreSQL 7.3.2, JDBC driver 7.3 build 108.


Re: JDBC polling data sources: what's i did wrong?

От
"Marcus Andree S. Magalhaes"
Дата:
Did you check postgres logs???

I have a similar example here, but couldn't make the Datasource singleton
to work...

Quoting Serg N Elin <esn@sumail.ru>:

> Hi there,
>
> here is a simple application which i wrote for testing purposes:
>
> ...
>
>  Jdbc3PoolingDataSource source = new Jdbc3PoolingDataSource();
>  source.setServerName("localhost");
>  source.setDatabaseName("cruz");
>  source.setUser("cruz");
>  source.setPassword(null);
>  source.setMaxConnections(5);
>
>       Connection conn = source.getConnection();
>
>       PreparedStatement st = conn.prepareStatement(
>           "INSERT INTO test (from_addr, "
>           + " to_addr, subject, body, received, message_id,in_reply_to)
> values (?,?,?,?,?,?,?)"
>           );
>       st.setString(1, "test");
>       st.setString(2, "test");
>       st.setString(3, "test");
>       st.setString(4, "test");
>       st.setDate(5, new java.sql.Date(new Date().getTime()));
>       st.setString(6,"test");
>        st.setString(7,"test");
>
>       int count = st.executeUpdate();
>
>       st.close();
>
>       conn.close();
>     }
>     catch (SQLException ex) {
>       ex.printStackTrace();
>     }
> then code executed there are no any data that you can seen in example in the
> table/// So the qestion is what's i'm doing wrong?
>
> jdk 1.4.1_01, PostgreSQL 7.3.2, JDBC driver 7.3 build 108.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>




-------------------------------
   http://www.vlinfo.com.br


Re: JDBC polling data sources: what's i did wrong?

От
Barry Lind
Дата:
Serg,

You didn't call commit().  So the changes are not saved.

--Barry

Serg N Elin wrote:
> Hi there,
>
> here is a simple application which i wrote for testing purposes:
>
> ...
>
>  Jdbc3PoolingDataSource source = new Jdbc3PoolingDataSource();
>  source.setServerName("localhost");
>  source.setDatabaseName("cruz");
>  source.setUser("cruz");
>  source.setPassword(null);
>  source.setMaxConnections(5);
>
>       Connection conn = source.getConnection();
>
>       PreparedStatement st = conn.prepareStatement(
>           "INSERT INTO test (from_addr, "
>           + " to_addr, subject, body, received, message_id,in_reply_to)
> values (?,?,?,?,?,?,?)"
>           );
>       st.setString(1, "test");
>       st.setString(2, "test");
>       st.setString(3, "test");
>       st.setString(4, "test");
>       st.setDate(5, new java.sql.Date(new Date().getTime()));
>       st.setString(6,"test");
>        st.setString(7,"test");
>
>       int count = st.executeUpdate();
>
>       st.close();
>
>       conn.close();
>     }
>     catch (SQLException ex) {
>       ex.printStackTrace();
>     }
> then code executed there are no any data that you can seen in example in the
> table/// So the qestion is what's i'm doing wrong?
>
> jdk 1.4.1_01, PostgreSQL 7.3.2, JDBC driver 7.3 build 108.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>