Re: [GENERAL] [JDBC] Problem with boolean type

2004-10-07 Thread Kris Jurka


On Thu, 7 Oct 2004, Johann Robette wrote:

 I use EJB to create a record in a table containing a Boolean field
 answered.
 The EJB method expects a Boolean object so I pass new Boolean(false) in
 order to create it as false.
 
 But I get the following error : 
 java.sql.SQLException: ERROR: column answered is of type boolean but
 expression is of type text

I don't see how that could be happening.  The attached test works fine for 
me and exercises every way I see to set a boolean.  Perhaps the EJB is 
internally converting this to a setString() call?  Could you investigate 
more into what actual driver calls are being made?

Kris Jurkaimport java.sql.*;

public class BoolTest {

public static void main(String args[]) throws Exception {
Class.forName(org.postgresql.Driver);
Connection conn = 
DriverManager.getConnection(jdbc:postgresql://localhost:5750/jurka,jurka,);

Statement stmt = conn.createStatement();
stmt.execute(CREATE TEMP TABLE tt (ans bool));
stmt.close();


PreparedStatement pstmt = conn.prepareStatement(INSERT INTO tt (ans) 
VALUES (?));
pstmt.setObject(1, new Boolean(false));
pstmt.executeUpdate();
pstmt.setBoolean(1, false);
pstmt.executeUpdate();
pstmt.setObject(1, new Boolean(false), Types.BIT);
pstmt.executeUpdate();
pstmt.setObject(1, new Boolean(false), Types.BOOLEAN);
pstmt.executeUpdate();
pstmt.close();

stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(SELECT ans FROM tt);
while (rs.next()) {
System.out.println(rs.getBoolean(1));
}
rs.close();
stmt.close();
conn.close();
}
}

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [GENERAL] JDBC problem

2004-05-11 Thread Carl E. McMillin
Hi,

...I'm getting error like this from the java side and the 
application stops working (and wont come back unless I restart...

How is the application invoked?  Is it a service (servlet instance, RMI
object-mediated, etc.), i.e. does a core-component run forever and spawn
helpers to handle requests?

I'd guess that you are slurping output from an external process'
STDOUT/STDERR and the process-control API noticed that one or both sides of
the conversation broke the underlying conduit (the pipe) between the
processes.

Carl |};-)



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Reynir Þór Hübner
Sent: Tuesday, May 11, 2004 3:37 AM
To: [EMAIL PROTECTED]
Subject: [GENERAL] JDBC problem 


I'm running an engine with 15 databases, with fair amount of load. Every 
4-5 days I'm getting error like this from the java side and the 
application stops working (and wont come back unless I restart) :

java.net.SocketException: Broken pipe
   at java.net.SocketOutputStream.socketWrite0(Native Method)
   at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
   at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
   at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:66)
   at java.io.BufferedOutputStream.write(BufferedOutputStream.java:110)
   at java.io.FilterOutputStream.write(FilterOutputStream.java:80)
   at org.postgresql.PG_Stream.Send(PG_Stream.java:87)
   at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:184)
   at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:71)
   at 
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection
.java:505)
   at 
org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.j
ava:360)
   at 
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.j
ava:48)
   at 
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statem
ent.java:176)
   at 
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statem
ent.java:163)
   at 
org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement
.java:162)
   at 
com.eplica.model.persistence.JDBCPersistenceHelper.findByUniqueSql(JDBCPersi
stenceHelper.java:704)


Does anyone know what this is about ?
I'm using Red hat Enterprise, and all the correct JDBC drivers etc.


thanx
-reynir

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


[GENERAL] JDBC problem 7.1

2001-04-26 Thread Loïc Courtois

Hello,

I have the following java source code:

This one work with pg 7.0.3 , but not with 7.1, with the following error
message:

java.lang.NullPointerException
at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:116)
at ouah.stats.Stats.go(Stats.java:242)
at daily.main(daily.java:54)

///BEGIN
///:
Statement statement;
ResultSet results, results2;

try {
statement = conn.createStatement();

if(statement.execute(SELECT ...)) {
results = statement.getResultSet();
while(results.next()) {
System.out.println(results.getInt(nb));

if(statement.execute(SELECT ... WHERE no =  +
results.getString(no) ... )) {
results2 = statement.getResultSet();
while(results2.next()) {
System.out.println(\t +
results2.getInt(nb));
}
results2.close();
}
}
results.close();
statement.close();
}
} catch (java.sql.SQLException e) { e.printStackTrace();}
///END//
/:


This one work with pg 7.1
///BEGIN
///:
Statement statement, s2;
ResultSet results, results2;

try {
statement = conn.createStatement();
s2 = conn.createStatement();

if(statement.execute(SELECT ...)) {
results = statement.getResultSet();
while(results.next()) {
System.out.println(results.getInt(nb));

   if(s2.execute(SELECT ... WHERE no =  +
results.getString(no) ... )) {
results2 = s2.getResultSet();
while(results2.next()) {
System.out.println(\t +
results2.getInt(nb));
}
results2.close();
}
}
results.close();
statement.close();
s2.close();
}
} catch (java.sql.SQLException e) { e.printStackTrace();}
///END//
/:


Please, could I have advice?

Thanks!!

Loic Courtois
Netpartage


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



[GENERAL] JDBC problem with Postgres 7.0.3

2001-02-23 Thread Santosh Rau

Hello,

I am using the postgres driver for my Java code (JDK 1.2.2) which came
with the  Postgres 7.0.3 tar file. I am trying get the name of a column
which is essentially the primary key in this table. Unfortunately, the
result set returned does not have any records(as shown below). This code

works fine on Oracle. I also tried jdbc7.0-1.2.jar but the same problem
occurs.

 Code 
  public String getUniqueRowName() throws SQLException{
DatabaseMetaData dma = m_Connection.getMetaData();
ResultSet rs = dma.getIndexInfo("", "", "table name", true,
false);
if(rs == null){
  return null;
}
rs.next(); No records here
String sIndex = rs.getString("COLUMN_NAME");
return sIndex;
  }

Any help is appreciated.

Thanks in advance for your time

Santosh Rau








[GENERAL] JDBC problem on Postgresql 7 beta 5

2000-05-02 Thread Jack Zhu

Hi,

PostgreSQL 7 Beta 5 on Red hat Linux 6.0
JDBC 6.5-1.1 driver, Java 1.1.7B, download JDBC driver from
http://www.retep.org.uk/postgres/

We have a a table which has a column col_a with 'timestamp' data type. When
insert time value to this column, we use format which is 'MM/DD/
HH24:MI:SS' (such as '05/01/2000 13:20:02'). Insertion is OK.

But when we try to read this column, the output is '05/01/2000
13:20:02.20-04', which is not what we need. We don't need the '.20-04' part
of the output, that is nano second and time zone part, otherwise the output
cannot work with JDBC driver.

Is there any ways make our app work without returning the 'nano and time
zone' part or make JDBC understand the 'timestamp' full output format? Thnx!

Error msg we got from running our app:
"
TAMP = 2000-04-03 00:00:00.0
GETTIME = 95473440
DATE = Mon Apr 03 00:00:00 EDT 2000
Bad Timestamp Format at 0 in 2000-04-03 12:12:12.12-04
at postgresql.jdbc1.ResultSet.getTimestamp(ResultSet.java:445)
at
com.netcom.netforensics.dbaccess.SQLObjectAccess.getProperty(SQLObjectAccess
.java:709)
"


Jack




Re: [GENERAL] jdbc problem

1999-10-16 Thread Jim Richards


I am using postgresql under linux.  Now that I need to
build up the jdbc driver for postgresql, when I make
under the directory /src/interfaces/jdbc.. I get an
error stating '(u' unexpected syntax... 

The version returned by the make is 1.0b4.  The
makeVersion.java file returns jdbc0 as the output and
so, the postgresql.jar file is not been created.

run

make jdbc1

for the version 1 driver (jdk 1.1) and

make jdbc2

for the version 2 driver (java2) ...

then for each build, run

 jar -cf postgresql.jar `find postgresql -name "*.class" -print`

to make the jar file.


--
Subvert the dominant paradigm
 http://www.cyber4.org/members/grumpy/index.html





[GENERAL] jdbc problem

1999-10-15 Thread soundar rajan

Hi,

I am using postgresql under linux.  Now that I need to
build up the jdbc driver for postgresql, when I make
under the directory /src/interfaces/jdbc.. I get an
error stating '(u' unexpected syntax... 

The version returned by the make is 1.0b4.  The
makeVersion.java file returns jdbc0 as the output and
so, the postgresql.jar file is not been created.

How do I go about this?  Any help would be
appreciated.

Thanks.
Soundar.  

__
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com