no insert after commit

hello

Im trying to insert newType to the data base "postgresql"

but I can't see it in the record when I try to use pgadmin

my connection is set to connection.setAutoCommit(false );

publicboolean new_type_vist(TypeVisit typevisit)throws DataAccessException

{

try

{

int result=0;

sqlInsertTypeVisit.setInt(1,typevisit.get_praticien().get_id_person());

if(typevisit.getType_suivant()==null)

{

sqlInsertTypeVisit.setInt(2,28);

}

else

{

sqlInsertTypeVisit.setInt(2,typevisit.getType_suivant().get_id_type());

}

sqlInsertTypeVisit.setString(3,typevisit.get_libelle_type());

sqlInsertTypeVisit.setBoolean(4,typevisit.get_visible());

sqlInsertTypeVisit.setInt(5,typevisit.getAfter_nb_of_days());

result = sqlInsertTypeVisit.executeUpdate();

if ( result == 0 )

{

connection.rollback();// rollback update

System.err.println("rool back type");

returnfalse;// update unsuccessful

}

System.out.println("new type will be commited");

connection.commit();

System.out.println("new type is commited");

returntrue;

}

catch ( SQLException sqlException )

{

sqlException.printStackTrace();

// rollback transaction

try

{

connection.rollback();// rollback update

System.err.println("rool back duree");// rollback update

returnfalse;// update unsuccessful

}

// handle exception rolling back transaction

catch ( SQLException exception )

{

thrownew DataAccessException( exception );

}

}

}

I can see the insert withen the connection ,but once Im out of the programme ,then I dont see the inserted record ?

I think it is a problem with commit ?

how can i debug this ?

do u see any thing that i cant see ?

[3341 byte] By [linuxchilda] at [2007-11-26 21:54:08]
# 1
i forget to say that when i call this function it return true ...
linuxchilda at 2007-7-10 3:48:56 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
for more info i get this in the log of postgresql 2007-03-16 15:43:27 LOG: could not receive data from client: Unknown winsock error 100612007-03-16 15:43:27 LOG: unexpected EOF on client connectionI will check with google to what does it mean ...
linuxchilda at 2007-7-10 3:48:56 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

> result = sqlInsertTypeVisit.executeUpdate();

> if ( result == 0 )

It isn't a good idea to rely on that sort of behavior. If it fails then it will throw an exception. If it succeeds in general drivers might return anything, including zero.

I am not even sure how that makes logical sense anyways. If it doesn't succeed what exactly are you rolling back?

jschella at 2007-7-10 3:48:56 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

thank you ,I think it was a bug from the database it self

It is working perfectly now ,I had to reinstall

the error I wrote from the log file of postgresql ,I had it because i did not close the connection at the end of my programme.

for the exception I have well traeted with the try and catch ,but what do you propose as a better solution ?

thnak you for ur answer .

linuxchilda at 2007-7-10 3:48:56 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
> for the exception I have well traeted with the try> and catch ,but what do you propose as a better> solution ?Get rid of the if check. It serves no purpose.
jschella at 2007-7-10 3:48:56 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...