473,606 Members | 2,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simultaneous use of JDBC and libpq

Hi,

I am wondering if it is thread-safe to use both JDBC and libpq
simultaneously.

On a Linux, JDBC is used by Tomcat and libpq is used by a client
software written in C language. So JDBC and libpq are used by two
different programs.
If the same row in the same table is updated (update SQL command)
through libpq and
read (select SQL command) by JDBC, then would it cause a thread problem?
I am not using any transaction, and using just select, update, and
sometimes insert.

I am using PostgreSQL 7.3.6 with pg73jdbc3.jar downloaded and libpq that
came with Redhat Enterprise 3.

Thank you very much in advance.

Bob


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

Nov 23 '05 #1
2 2373
alltest1 wrote:
Hi,

I am wondering if it is thread-safe to use both JDBC and libpq
simultaneously.

On a Linux, JDBC is used by Tomcat and libpq is used by a client
software written in C language. So JDBC and libpq are used by two
different programs.
If the same row in the same table is updated (update SQL command)
through libpq and
read (select SQL command) by JDBC, then would it cause a thread problem?
I am not using any transaction, and using just select, update, and
sometimes insert.


There are no threads involved here - Tomcat/client-app will be different
processes, and both have their own connection to the database.

You might need to consider concurrency issues within the database
though, e.g. assume your bank account has $B!r(B100 and TOMCAT is debiting
$B!r(B10 while the other app is crediting $B!r(B15

TOMCAT: SELECT amount FROM bank_accounts WHERE acct_id = 1;
OTHER: SELECT amount FROM bank_accounts WHERE acct_id = 1;
TOMCAT: UPDATE bank_accounts SET amount=90 WHERE acct_id = 1;
OTHER: UPDATE bank_accounts SET amount=115 WHERE acct_id = 1;

Oops - not $B!r(B105 at all. To solve this, you need to lock the table or the
row(s) in question, e.g.
SELECT FOR UPDATE ... WHERE acct_id = 1;]#

See the section on "concurrenc y control" in the manuals for full details.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #2
Yes, it is safe. The JDBC and the libpq app will share nothing between
each other, so there can not be any threading issues between them.
You can only have thread safety issues inside the same application which
uses multiple threads sharing resources between each other.

Cheers,
Csaba.

On Wed, 2004-06-23 at 16:24, alltest1 wrote:
Hi,

I am wondering if it is thread-safe to use both JDBC and libpq
simultaneously.

On a Linux, JDBC is used by Tomcat and libpq is used by a client
software written in C language. So JDBC and libpq are used by two
different programs.
If the same row in the same table is updated (update SQL command)
through libpq and
read (select SQL command) by JDBC, then would it cause a thread problem?
I am not using any transaction, and using just select, update, and
sometimes insert.

I am using PostgreSQL 7.3.6 with pg73jdbc3.jar downloaded and libpq that
came with Redhat Enterprise 3.

Thank you very much in advance.

Bob


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

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1377
by: Marco Vezzoli | last post by:
Hi all, I'm using solaris 8 gcc 3.0.1 postgres 7.3.4 psycopg 1.1.2 apache 1.3.19 python 2.1.1 mod_python 2.7.8 compiled with DSO
1
5681
by: Phil Campaigne | last post by:
Hi All, Took a break from developing on pgsql 7.3 to set up network printing where I added another host(localhost 193.168.1.2) in red hat network settings. Later, I could start postmaster but when I started psql I got the following error when I issue this command: psql -h localhost -U postgres nba -bash-2.05b$ psql -h localhost -U postgres nba psql: error while loading shared libraries: libpq.so.3: cannot open
175
11317
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I think is PostgreSQL would have less USP's (Uniqe Selling Points
1
3378
by: Semaj | last post by:
Environment: DB2 8.1.4; Windows 2000 We are evaluating the feasibility of upgrading our production DB from 7.2 to 8.1. During this process we've encountered an error when starting our application program, which establishes several JDBC connections to the database. However, this problem can be reproduced in a variety of ways, including using the CLP. Here are the steps required to reproduce the problem using the command-line...
2
2383
by: Jim Crate | last post by:
I'm trying to build a client program to access a database using the libpq interface on MacOS X 10.3.3 using CodeWarrior 9. PostgreSQL is at version 7.4.2. It compiles ok, but I get a link error. I have linked to libpq.a, because I got different errors before I did that. Here is the error I'm getting right now: Link Error: undefined: '@_1' (code) Referenced from 'pqSetenvPoll' in libpq.a Referenced from 'pqSetenvPoll' in libpq.a
2
2246
by: Adam Smith | last post by:
Installation of 7.4.2, even with just ./configure : gmake step ==> _________________________________________________ gmake: Leaving directory `/usr/home/smith/Temp_holding/staging-area/postgresql/postgresql-7.4.2/src/backend/parser' gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations pg_dump.o common.o pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o pg_backup_files.o pg_backup_null.o
15
2488
by: Dino Vliet | last post by:
Hi folks, probably this is a question you've heard so many times but I wasn't able to find a solution to it. I'm using a shell script to create a textfile for me. It looks like #!/usr/local/bin/bash psql -c "select foo from bar;" -d database1 -t psql -c "\q" -d database1 exit 0
4
1592
by: Wayne Fang | last post by:
Hi, For various reasons (parallel structure with existing code, commonality of concepts, etc), we have C language functions implemented that use libpq to make a new connection to the same Postgres server. Yes, I realize libpq is meant for clients and SPI for backends. The question is, are there any technical problems with this? Will using libpq in the backend do Bad Things in unexpected areas/ways? The environment ranges from: Postgres...
1
2090
by: loosecannon_1 | last post by:
Hello everyone, I am hoping someone can help me with this problem. I will say up front that I am not a SQL Server DBA, I am a developer. I have an application that sends about 25 simultaneous queries to a SQL Server 2000 Standard Edition SP4 running on Windows 2000 Server with 2.5 GB of memory. About 11 of these queries are over views (all over the same table) and these queries are all done from JDBC but I am not sure that matters. ...
0
8015
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7951
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5966
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1553
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1296
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.