Hi all,
I'm sure this is really really easy but I do need some help.
I'm writing a java stored prcedure to manage the assignment of IP
addresses to mac addresses for a network device database I've got.
Basically a user fills in a template detailing information about
themselves, the location of the pc and its mac address. The SP takes
this input info and scans a database table that stores the assigned ip
addresses in a subnet looking for the next free ip address and then
performs a record insert using the free address. Obviously you don't
want two instances scanning the same subnet for the next free ip
address at the same time.
Once the SP has been called, I want any other requests to the sp to be
queued up while that particular invocation has completed - just in
case there are 2 people trying to register information on the same
subnet. When the call completes, the next request in the queue can be
processed.
How do i implement the above
TIA
Alex 5 2059
"Alex" <A.******@hull. ac.uk> wrote in message
news:b2******** *************** ***@posting.goo gle.com... Hi all,
I'm sure this is really really easy but I do need some help.
I'm writing a java stored prcedure to manage the assignment of IP addresses to mac addresses for a network device database I've got. Basically a user fills in a template detailing information about themselves, the location of the pc and its mac address. The SP takes this input info and scans a database table that stores the assigned ip addresses in a subnet looking for the next free ip address and then performs a record insert using the free address. Obviously you don't want two instances scanning the same subnet for the next free ip address at the same time.
Once the SP has been called, I want any other requests to the sp to be queued up while that particular invocation has completed - just in case there are 2 people trying to register information on the same subnet. When the call completes, the next request in the queue can be processed.
How do i implement the above
I don't think this is really a DB2 issue as much as a Java issue. Have a
look at the synchronized keyword in Java for one possible approach. Also,
consider the idea of using multiple Java threads. A discussion of this
approach occurs in the Java Tutorial starting at http://java.sun.com/docs/books/tutor...ithreaded.html
The following article (and its sequels) consider both approaches: http://www-106.ibm.com/developerwork...ry/j-threads1/
Rhino
Alex wrote: Hi all,
I'm sure this is really really easy but I do need some help.
I'm writing a java stored prcedure to manage the assignment of IP addresses to mac addresses for a network device database I've got. Basically a user fills in a template detailing information about themselves, the location of the pc and its mac address. The SP takes this input info and scans a database table that stores the assigned ip addresses in a subnet looking for the next free ip address and then performs a record insert using the free address. Obviously you don't want two instances scanning the same subnet for the next free ip address at the same time.
You don't need to do anything special.
DB2 will handle this for you with row and/or table locks, provided
you're using the proper isolation level (the default, CS, should do
the trick) and you are handling the search/insert as a single
transaction.
Good luck,
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Ian <ia*****@mobile audio.com> wrote in message news:<40******* *@corp.newsgrou ps.com>... Alex wrote:
Hi all,
I'm sure this is really really easy but I do need some help.
I'm writing a java stored prcedure to manage the assignment of IP addresses to mac addresses for a network device database I've got. Basically a user fills in a template detailing information about themselves, the location of the pc and its mac address. The SP takes this input info and scans a database table that stores the assigned ip addresses in a subnet looking for the next free ip address and then performs a record insert using the free address. Obviously you don't want two instances scanning the same subnet for the next free ip address at the same time.
You don't need to do anything special.
DB2 will handle this for you with row and/or table locks, provided you're using the proper isolation level (the default, CS, should do the trick) and you are handling the search/insert as a single transaction.
Hmmm as a single transaction, don't think my sql is up to that.
At the moment I've gor a procedure that returns the ip address to use.
The internals of this function connects to the database ,performs a
table search returning a resultset containing an ascending ordered
list of all the ip addresses in a particular subnet. I then start at
the 1st one and read through the returned values checking that they
are in sequence (2,3,4, etc ). When I find a gap, I use the "prev"
value + 1
This value is then used in a separate insert statement to add data to
the table.
If there's a way of combining the two I'd certainly like to know.
alex
"Rhino" <rh****@NOSPAM. sympatico.ca> wrote in message news:<1J******* *************@n ews20.bellgloba l.com>... "Alex" <A.******@hull. ac.uk> wrote in message news:b2******** *************** ***@posting.goo gle.com... Hi all,
I'm sure this is really really easy but I do need some help.
I'm writing a java stored prcedure to manage the assignment of IP addresses to mac addresses for a network device database I've got. Basically a user fills in a template detailing information about themselves, the location of the pc and its mac address. The SP takes this input info and scans a database table that stores the assigned ip addresses in a subnet looking for the next free ip address and then performs a record insert using the free address. Obviously you don't want two instances scanning the same subnet for the next free ip address at the same time.
Once the SP has been called, I want any other requests to the sp to be queued up while that particular invocation has completed - just in case there are 2 people trying to register information on the same subnet. When the call completes, the next request in the queue can be processed.
How do i implement the above I don't think this is really a DB2 issue as much as a Java issue. Have a look at the synchronized keyword in Java for one possible approach. Also, consider the idea of using multiple Java threads. A discussion of this approach occurs in the Java Tutorial starting at http://java.sun.com/docs/books/tutor...ithreaded.html
The following article (and its sequels) consider both approaches: http://www-106.ibm.com/developerwork...ry/j-threads1/
Rhino
Many thnaks for this, some weekend reading methinks
:-))
Alex wrote: Ian <ia*****@mobile audio.com> wrote in message news:<40******* *@corp.newsgrou ps.com>... Alex wrote:
> Hi all, > > I'm sure this is really really easy but I do need some help. > > I'm writing a java stored prcedure to manage the assignment of IP > addresses to mac addresses for a network device database I've got. > Basically a user fills in a template detailing information about > themselves, the location of the pc and its mac address. The SP takes > this input info and scans a database table that stores the assigned ip > addresses in a subnet looking for the next free ip address and then > performs a record insert using the free address. Obviously you don't > want two instances scanning the same subnet for the next free ip > address at the same time.
You don't need to do anything special.
DB2 will handle this for you with row and/or table locks, provided you're using the proper isolation level (the default, CS, should do the trick) and you are handling the search/insert as a single transaction.
Hmmm as a single transaction, don't think my sql is up to that.
At the moment I've gor a procedure that returns the ip address to use. The internals of this function connects to the database ,performs a table search returning a resultset containing an ascending ordered list of all the ip addresses in a particular subnet. I then start at the 1st one and read through the returned values checking that they are in sequence (2,3,4, etc ). When I find a gap, I use the "prev" value + 1
This value is then used in a separate insert statement to add data to the table.
All this is done inside the procedure?
Do you execute a COMMIT or ROLLBACK statement somewhere in between? If not
then, you already do this in a single transaction (aka unit of work).
p.s: It might be a good idea to read a SQL book that covers the basics of
SQL statements and transactions.
--
Knut Stolze
Information Integration
IBM Germany / University of Jena This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dimitris |
last post by:
I'm using ADO.NET to call a stored procedure that runs the "BACKUP" command
on selected databases. Is there any way I can capture the text output of the
stored proc and return it to ADO.NET for displaying in my application?
When I run the stored procedure from SQL Query Analyzer, I get an output (in
the messages tab) like:
Processed 1496 pages for database 'OldBO', file 'TB_BackOffice_Data' on file
1.
Processed 1 pages for database...
|
by: dinesh prasad |
last post by:
I'm trying to use a servlet to process a form, then send that data to
an SQL server stored procedure. I'm using the WebLogic 8 App. server.
I am able to retrieve database information, so I know my application
server can talk to the database.
I've determined the failure occurs when the the following statement is
executed: cstmt.execute(); (due to the failure of println statements
placed afterwards). I get the following error after trying to...
|
by: Alex |
last post by:
Hi all,
I am trying to install a java stored procedure via the windows
development centre.
The linux box is running 8.1 FP4 as is the windoze platform. If I am
on the linux box i can install the sample jdbc stored procedures o.k.
For the purpose of this test I created a sample procedure that
executes "select * from department" when conected to the sample
database on the linux box.
|
by: Kent Lewandowski |
last post by:
hi all,
Recently I wrote some stored procedures using java jdbc code
(admittedly my first stab) and then tried to implement the same within
java packages (for code reuse). I encountered problems doing this.
I wanted to implemented a generic "Helper" class like this:
/**
* Helper
|
by: Pakna |
last post by:
Hi, is there any way to call a JAVA stored procedure from a SQL Trigger?
We are having difficulties with this and cannot verify whether DB2 even
*has* this capability?
Thank you very much....
| |
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
|
by: satish mullapudi |
last post by:
Hi,
I am using DB2 v8.2 & jdk 1.4.
1. I have a java program which returns an array which contains 1 to 5
numbers.
The code:
public class ArrayTest
{
public static final int ARRAY_SIZE = 5;
public static int array()
{
|
by: amgupta8 |
last post by:
Note: This problem occurred when I updated the JDK from 1.3.1 to 1.4.1 or 1.4.2.
Nothing else was changed in the code, other than updating the JDK on the database server (dbm cfg parm jdk_path) and recompiling/executing the code with 1.4.1 (deploying the newly compiled stored procedure code as well).
This is the original exception that I got before I tried any code modifications:
java.io.IOException: invalid offset/length
at...
|
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...
|
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,...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |