Solaris vs Linux For Multithreaded Application
Hi all,
I am having a Multithreaded Java application which is used to monitor devices in a network (NMS). After collecting the data from the devices, this will update the data in the database. (Usualy there will be lot of device around 25000) . There will be lot of database updation. I am planning to run this application in a server.
But now I am confused in selecting which platform (which os) I have to use. There are two options for me. Either to use Linux or Solaris.
Can anyone help me in selecting the platform. Since my application is multithreaded , please tell me which of these OS will give the best performance
Thanks in advance
There's no way to tell which one performs better without testing it. Both have reasonably mature and stable multitasking and multi threading. Why don't you write the application and try it on both platforms?
Similar Messages
-
How to configure ENV and DB for multithreaded application?
Hi,
From document, I know DB_THREAD must be checked for both ENV and DB, but , I don't know which one is best choice for multithreaded application while facing DB_INIT_LOCK and DB_INIT_CDB. In my application, there maybe multi readers and writers at the same time, should I use DB_INIT_LOCK instead of DB_INIT_CDB? what other flags should I use?
DB_INIT_CDB provides multiple reader/single writer access while DB_INIT_LOCK should be used when multiple processes or threads are going to be reading and writing a Berkeley DB database.
Thanks for your seggestions and answers.Thanks for the explanation,
The Berkeley DB Concurrent Data Store product
allows for multiple reader/single writer access
to a database. This means that at any point in time,
there may be either multiple readers accessing a
database or a single writer updating the database.
Berkeley DB Concurrent Data Store is intended for
applications that need support for concurrent updates
to a database that is largely used for reading.
If you are looking to support multiple readers and
multiple writers then take a look at the Transactional
Data Store product
(http://download.oracle.com/docs/cd/E17076_02/html/programmer_reference/transapp.html)
In this case the Environment is typically opened with:
DB_INIT_MPOOL, DB_INIT_LOCK, DB_INIT_LOG, and DB_INIT_TXN.
Let me know if I missed any of your question.
Thanks,
Sandra -
PersistenceManager Patterns for Multithreaded Applications
Hi,
I'm looking for a good way, how to use Kodo JDO in a multithread application
(actually Tomcat ;). The most easy thing is perhaps, to use only one
persistence
manager for the entire application, i.e. for all threads. Another solution
might be,
to create a PersistenceManager for each HTTP request. I don't like the
solution,
to have one PeristenceManager per session, because I expect thousands
concurrent
users. What I'm concerned with is the number of data base connections in
this
case.
So my question to you is, what pattern do you use in your web applications?
When do you create and close the PersistenceManagers to free resources?
Has anybody alreay tried different patterns and compared the performance?
Is there something like a best practice?
MichaelThe other nice thing about the filter is that it should be easy to
selectivly store and retrieve the PM in a user's session if they have a
longer running transaction that spans multiple requests.
So far, I've simply been passing the PM to each service method, although I
don't particularliy like that approach. I haven't had time to try anything
different yet and it isn't TOO bad, although I have a few ideas:
1. The hashtable method you mentioned. I see there is a "Registry" pattern
in the "Patterns of Enterprise Application Architecture" book I'm currently
reading, but haven't gotten to it yet. I think it is close to what you
mentioned.
2. Retrieve the PM through JNDI. I don't know, however, if I can set up a
PM in JNDI the way that the CurrentTransaction JNDI lookup works with
container managed transactions.
"Michael" <[email protected]> wrote in message
news:[email protected]...
I've never used a servlet filter before but I must say that is the most
elegant approach I've seen, thanks for sharing that. How do you pass thePM
to the service layer? Do you store it in a hashtable with the current
thread as a key or do you pass it in to each service method?
Thanks,
Michael
"Nathan Voxland" <[email protected]> wrote in message
news:[email protected]...
We've created the PersistenceManager in a filter and attached it to the
request object. That way, the persistence manager can be accessed fromthe
Struts Action, JSP Page, and anything else we do, plus we don't have to
worry about closing it because it is closed by the filter after
everything
is done (Even if an exception is thrown)
Here is the code:
public void doFilter(final ServletRequest request, final ServletResponse
response, FilterChain chain) throws IOException, ServletException {
PersistenceManager pm = getPersistenceManager();
request.setAttribute(JDO_PERSISTENCE_MANAGER, pm);
try {
chain.doFilter(request, response);
} finally {
if (pm.currentTransaction().isActive()) {
pm.currentTransaction().rollback();
pm.close();
"Michael" <[email protected]> wrote in message
news:[email protected]...
I currently doing exactly this: getting a persistence manager at the
beginning of a jsp page and close it at the end of the jsp page.
When you use <jsp:include ...>, you must be careful not to close the
persistence manager to early. I do it like this:
This sounds like a good approach, especially the hashtable with the
thread
as the key. The only issue I see is if you create the PM in the JSPpage,
often an Action is executed before the JSP is called. This is why I
was
thinking of creating the PM in the struts request processor, it'salways
called for every request. -
MultiThreaded Application == multiProcessor Application
Using XTools 2.2
I wrote a multithreaded application with 4 threads that appears to run equally fast on a single processor Mac (PowerBook G4) and a multiprocessor Mac (G5 Quad). The only speed increase I see (2X) can be explained from the fact that the Quad has a faster clock than the PowerBook.
Threads were created with Cocoa (NSThread). I can test that the threads are created and carry out their caclulations (calculations/thread are set for approx 30 seconds for the tests).
I've checked the documentation from apple but haven't found any issue that seem appropriate. Is there a compiler flag?? Some obscure directive?? Help please....
-thazlettThank you for the replies.
One of the primary issues pointed out by Apple in their documentation for multithreading applications is the difficulties in shared resources.
I have split threads to work on separate, but identical, objects that each carry out a CPU intensive task. Each creates a large vector that will all eventually be summed. I have tried to comment out everything (like a counter) that might be shared, but no speed increases. I have instantiated the objects within the Interface builder (interface builder causing some invisible connection here?) and set their variables before splitting off separate threads for the individual computations. The variables names within the objects are identical, but are local (I assume so).
I will continue to screen my code for something that is being shared since this is the most likely problem. -
Need Best Practice for Migrating from Solaris to Linux
Hi Team,
We are migrating our Data Center from Solaris to Linux and our EBS 11i, database 10g (10.2.0.5) is 6TB. Please let us know the Best Practice to Migrate our EBS 11.5.10.2 from Solaris to Linux RHEL 5.
we require Database 10g (10.2.0.5) on Linux x86-64 RHEL 5 and Application EBS on Linux x86 RHEL 5. Please let us know for any details.
EBS version: 11.5.10.2
DB version: 10.2.0.5
We have checked the certifications in Oracle support.
Oracle EBS 11.5.10.2 is not certified with Linux x86-64 RHEL 5.
Oracle EBS 11.5.10.2 is certified on Linux x86 RHEL 5.
So we require Database 10g (10.2.0.5) on Linux x86-64 RHEL 5 and Application EBS on Linux x86 RHEL 5.
Thank You.You can transportable tablespace for the database tier node.
https://blogs.oracle.com/stevenChan/entry/10gr2_xtts_ebs11i
https://blogs.oracle.com/stevenChan/entry/call_for_xtts_eap_participants
For the application tier node, please see:
https://blogs.oracle.com/stevenChan/entry/migrate_ebs_apptiers_linux
https://blogs.oracle.com/stevenChan/entry/migrating_oracle_applications_to_new_platforms
Thanks,
Hussein -
How to Debug C++ Multithreaded Application in Solaris
Hi All,
I am working in Solaris Sparc 5.8 Machine. I need to debug Multithreaded C++ Application in Unix Environment.
I am using dbx debugger.
Please explain me how to debug multithreaded applications. if possible please explain me with example.
Thanks in Advance.
Thanks & Regards,
Vasu1. Look over the dbx manual that comes with Sun Studio. Dbx includes many features for debugging MT code.
2. If you have specific questions after reading the manual and trying out the features, ask them in the debugger forum:
http://forum.sun.com/forum.jspa?forumID=257 -
Oracle Application R12.1.1 Migration from Solaris to Linux 64-bit
Hi,
Our existing System:
On Solaris 9:
Database 10.2.0.2
EBS 11.5.10.2
We are planning to Upgrade the system to
Database 11.2.0.3
EBS R12.1.3
We also want to migrate to RHEL 5 64-bit.
Please let me know if you have experience with respect to the following issues:
1. Can I use *Application Tier Platform Migration with Oracle E-Business Suite Release 12 [ID 438086.1]* as reference for my scenario? The document mentions that only Windows is supported as the source platform.
2. When they copy APPL_TOP from source to target - how the binaries from source operating system will work on target operating system? Else, are they platform independent?
3. Will the following approach work?
a. Migrate 10.2.0.2 database from source (Solaris) to target (RHEL 5 64-bit).
b. Upgrade 10.2.0.2 database to 11.2.0.3 on target.
c. Install R12.1.1 in upgrade mode on target.
d. Retrofit customization.
e. Upgrade R12.1.1 to R12.1.3
Also can you recommend best practise for Migrating database?
Thanks in advance.Note: Application Tier Platform Migration with Oracle E-Business Suite Release 12 (Doc ID 438086.1) reads: "The instructions in this document are for migration to a target UNIX/Linux platform. At present, Windows is only supported as a source platform."
Note the word SOURCE. So the restriction is Windows cannot be used as a TARGET platform, but other platforms can.
The content of the APPL_TOP is re-used in the Target environment, except for the binaries; these are delivered by applying the "customer-specific update" as in Note : Application Tier Platform Migration with Oracle E-Business Suite Release 12 (Doc ID 438086.1)
For information on the database migration check Note: 10g Release 2 Export/Import Process for Oracle Applications Release 11i (Doc ID 362205.1) and http://blogs.oracle.com/stevenChan/entry/migrating_ebusiness_suite_databases_between_platfo
The scenario seems OK, but needs to be tested of course.
For information related to upgrading the database for the EBS upgrade check Note: Database Preparation Guidelines for an E-Business Suite Release 12.1.1 Upgrade (Doc ID 761570.1)
Regards, Carlo. -
Online Links for Multithreading C++ Application in Unix
Hi Everybody,
I am working in Solaris Sparc 5.8 Machine. I need to implement Multithreading for C++ Application in Unix Environment.
It would be of great help if you can mention any website or online links which gives examples of how to do Multithreaded Programming for C++ Application in Unix Environment.
Thanking you in Advance.
Thanks & Regards,
VasuThere are two questions there, threading on Solaris is well documented on docs.sun.com, just search for something like pthread_create.
How you use the C APIs in you C++ code is down to you. You could have a look at boot threads for one possible solution.
Ian -
Solaris 10 zone config for one application
I have a Solaris 10 x86 server with 48GB of memory and 8 CPUs (although I believe hyperthreading is turned on because prsinfo shows 16 CPUs). The server is dedicated to one big application which spawns many processes/threads. Performance is extremely important for this application so I need to give it all of the resources possible.
I tried just allowing the application to run in the global zone because there's nothing else it will interfere with (aside from the OS) but I couldn't get it to utilize all of the CPUs this server has. My guess is the global zone is only designed for running the OS and playing traffic cop for the other zones, so it's not suited for running applications. Is that correct?
So my question is, assuming I do need to setup a dedicated zone for this monster application, how do I configure it to dedicate all CPUs and all memory (or as close to all of it as I can get)?
Also, is there some default limit on how much CPU % a process can have? Because I have tried getting one process to utilize 100% of a CPU and can't get anywhere near that... unless prstat doesn't display per CPU utilization information.
Any help would be appreciated.Kupacmac wrote:
I have a Solaris 10 x86 server with 48GB of memory and 8 CPUs (although I believe hyperthreading is turned on because prsinfo shows 16 CPUs). The server is dedicated to one big application which spawns many processes/threads. Performance is extremely important for this application so I need to give it all of the resources possible.
I tried just allowing the application to run in the global zone because there's nothing else it will interfere with (aside from the OS) but I couldn't get it to utilize all of the CPUs this server has. My guess is the global zone is only designed for running the OS and playing traffic cop for the other zones, so it's not suited for running applications. Is that correct?No. Unless you have dedicated CPUs to zones (so they are not available to the global zone), or unless you're running under a project which restricts CPU usage, the global zone has access to all virtual CPUs.
Can you see your process spawning threads? How much CPU is it able to use?
Also, is there some default limit on how much CPU % a process can have? Because I have tried getting one process to utilize 100% of a CPU and can't get anywhere near that... unless prstat doesn't display per CPU utilization information.One thread can only use one CPU. So you'd either need to run 16 single threaded processes, or your process would need to spawn 16 threads that were CPU-heavy. No, there's no default limit on a process.
Darren -
Best Unix skills to have AIX, Solaris or Linux Red Hat for SAP
Hello, I was wondering what would be the best Unix certification I should get in order to be
more marketable as a SAP Netweaver Administrator. IBM AIX, Sun Solaris or Linux Redhat.
Thanks for any comments and feedback
Steve.Thanks for the reply back. Its a hard question to get some answers for. If you had to make a guess from your own experience or work site what Unix version would it be. Thanks.
You forgot one big vendor: HP - with their HP-UX
I´d say "if you know one you can learn all".
Unix platforms are somewhat standardized (POSIX, SYSV etc.) so if you "know" one, it´s not that much work to learn a second one since the basics are similar, however, each OS has its specialities.
I have seen a chart with OS distributions some time ago, roughly 50 % was Windows, the rest was shared among the other Unix platforms almost equally with a small part being more "exotic" (System i, z/OS).
I´d also say that this is industry dependent. The banking sector may have - historically - more IBM (and hence AIX), manufacturing industry may also historically have more HP-UX, Universities may have more Solaris environments due to the historical closeness of Sun to education sector (note: those are assumptions). Linux may be used from all of them as "Unix"-similar alternative on Intel/AMD platforms.
Markus -
Need clarification on Solaris 10 upgrade for E Business suite application
Hi All,
Server details :
(1)Database tier : Sun Solaris 8 - 64 Bit
(2)Application tier ( E Business suite application services ): Sun Solaris 8 - 64 Bit
(3)Application tier ( E Business suite External tier - DMZ configuration ) : Sun Solaris 8 - 64 Bit
(4)10gAS and discoverer : Sun Solaris 8 - 64 Bit
We are planning to upgrade the Database tier (1) and Application tier (2) to Sun solaris 10 and leave the Application tier {
External - DMZ configuration } ( 3) and 10gAS and discoverer ( 4 ) with Sun
solaris 8 .
Please let us know if we will be having issues if we perform the OS upgrade in such a way.
Thanks & Regards,
RakeshRakesh,
There should be no issues with this upgrade path. Just make sure you relink all binaries after an OS Upgrade to ensure that everything is working as expected.
- Take a backup of the application/database
- Upgrade the OS
- Relink all binaries
- Start up the application/database
- Take another backup once you confirm that everything works properly
Note: 356878.1 - How to relink the whole Applications 11i Installation
https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=356878.1
Note: 131321.1 - How to Relink Oracle Database Software on UNIX
https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=131321.1
Note: 407055.1 - Process To Upgrade the Operating System and Oracle Database Server
https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=407055.1
Regards,
Hussein -
Installing JRE for J2SE application on fanless linux mini pc.
Good afteroon.
I want install a JRE for J2SE application on mini pc fanless .It is possible?
What about hardware settings,performance of this mini pc?
Bye.Was wondering this myself. Cannot find a class path on ubuntu. if there is one at all.
-
Why keyboard and mouse right click not working in Solaris and Linux?
Hi all,
I have two problems:
1) I am working on AWT/Swing application and its working fine in window enviornment,but while running on solaris and linux mouse right-click option window not poping up.
2) Ctrl+c,Ctrl+v,Home and End keyboard key are not working in solaris and linux OS for same application.
Pls provide me some solution for these problem.
-DineshHi Nik,
Thanks for reply. I found some solution for the above problem.
For mouse right click there was problem in my source code.I have not implemented the mousePressed() method
In case of keyboard Home, End and arrow key working fine after exporting AWTUSE_TYPE4_PATCH=false; in solaris and linux
But still Ctrl-c and Ctrl-v not working.
I am using JDK1.5.0_07+Eclipse IDE 3.1
-Dinesh -
Pro*c multithreaded application has memory leak
Hi there,
I posted this message a week ago in OCI section, nobody answer me.
I am really curious if my application has a bug or the pro*c has a bug.
Anyone can compile the sample code and test it easily.
I made multithreaded application which queries dynamic SQL, it works.
But the memory leaks when i query the SQL statement.
The more memory leaks, the more i query the SQL statement, even same SQL
statement.
I check it with top, shell command.
My machine is SUN E450, Solaris 8. Oracle 9.2.0.1
Compiler : gcc (GCC) 3.2.2
I changed source code which is from
$(ORACLE_HOME)/precomp/demo/proc/sample10.pc
the sample10 doesn't need to be multithreaded. But i think it has to work
correctly if i changed it to multithreaded application.
the make file and source code will be placed below.
I have to figure out the problem.
Please help
Thanks in advance,
the make file is below
HOME = /user/jkku
ORA = $(ORACLE_HOME)
CC = gcc
PROC = proc
LC_INCL = -I$(HOME)/work/dbmss/libs/include
lc_incl = include=$(HOME)/work/dbmss/libs/include
SYS_INCL =
sys_incl =
ORA_INCL = -I. \
-I$(ORA)/precomp/public \
-I$(ORA)/rdbms/public \
-I$(ORA)/rdbms/demo \
-I$(ORA)/rdbms/pbsql/public \
-I$(ORA)/network/public \
-DSLMXMX_ENABLE -DSLTS_ENABLE -D_SVID_GETTOD
INCLUDES = $(LC_INCL) $(SYS_INCL) $(ORA_INCL)
includes = $(lc_incl) $(sys_incl)
LC_LIBS =
SYS_LIBS = -lpthread -lsocket -lnsl -lrt
ORA_LIBS = -L$(ORA)/lib/ -lclntsh
LIBS = $(LC_LIBS) $(SYS_LIBS) $(ORA_LIBS)
# Define C Compiler flags
CFLAGS += -D_Solaris64_ -m64
CFLAGS += -g -D_REENTRANT
# Define pro*c Compiler flags
PROCFLAGS += THREADS=YES
PROCFLAGS += CPOOL=YES
# Our object files
PRECOMPS = sample10.c
OBJS = sample10.o
.SUFFIXES: .o .c .pc
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $*.c
.pc.c:
$(PROC) $(PROCFLAGS) $(includes) $*.pc $*.c
all: sample10
sample10: $(PRECOMPS) $(OBJS)
$(CC) $(CFLAGS) -o sample10 $(OBJS) $(LIBS)
clean:
rm -rf *.o sample10 sample10.c
the source code is below which i changed the oracle sample10.pc to
multithreaded application.
Sample Program 10: Dynamic SQL Method 4
This program connects you to ORACLE using your username and
password, then prompts you for a SQL statement. You can enter
any legal SQL statement. Use regular SQL syntax, not embedded SQL.
Your statement will be processed. If it is a query, the rows
fetched are displayed.
You can enter multi-line statements. The limit is 1023 characters.
This sample program only processes up to MAX_ITEMS bind variables and
MAX_ITEMS select-list items. MAX_ITEMS is #defined to be 40.
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <sqlda.h>
#include <stdlib.h>
#include <sqlcpr.h>
/* Maximum number of select-list items or bind variables. */
#define MAX_ITEMS 40
/* Maximum lengths of the names of the
select-list items or indicator variables. */
#define MAX_VNAME_LEN 30
#define MAX_INAME_LEN 30
#ifndef NULL
#define NULL 0
#endif
/* Prototypes */
#if defined(__STDC__)
void sql_error(void);
int oracle_connect(void);
int alloc_descriptors(int, int, int);
int get_dyn_statement(void);
void set_bind_variables(void);
void process_select_list(void);
void help(void);
#else
void sql_error(/*_ void _*/);
int oracle_connect(/*_ void _*/);
int alloc_descriptors(/*_ int, int, int _*/);
int get_dyn_statement(/* void _*/);
void set_bind_variables(/*_ void -*/);
void process_select_list(/*_ void _*/);
void help(/*_ void _*/);
#endif
char *dml_commands[] = {"SELECT", "select", "INSERT", "insert",
"UPDATE", "update", "DELETE", "delete"};
EXEC SQL INCLUDE sqlda;
EXEC SQL INCLUDE sqlca;
EXEC SQL BEGIN DECLARE SECTION;
char dyn_statement[1024];
EXEC SQL VAR dyn_statement IS STRING(1024);
EXEC SQL END DECLARE SECTION;
EXEC ORACLE OPTION (ORACA=YES);
EXEC ORACLE OPTION (RELEASE_CURSOR=YES);
SQLDA *bind_dp;
SQLDA *select_dp;
/* Define a buffer to hold longjmp state info. */
jmp_buf jmp_continue;
char *db_uid="dbmuser/dbmuser@dbmdb";
sql_context ctx;
int err_sql;
enum{
SQL_SUCC=0,
SQL_ERR,
SQL_NOTFOUND,
SQL_UNIQUE,
SQL_DISCONNECT,
SQL_NOTNULL
int main()
int i;
EXEC SQL ENABLE THREADS;
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
/* Connect to the database. */
if (connect_database() < 0)
exit(1);
EXEC SQL CONTEXT USE :ctx;
/* Process SQL statements. */
for (;;)
/* Allocate memory for the select and bind descriptors. */
if (alloc_descriptors(MAX_ITEMS, MAX_VNAME_LEN, NAME_LEN) != 0)
exit(1);
(void) setjmp(jmp_continue);
/* Get the statement. Break on "exit". */
if (get_dyn_statement() != 0)
break;
EXEC SQL PREPARE S FROM :dyn_statement;
EXEC SQL DECLARE C CURSOR FOR S;
/* Set the bind variables for any placeholders in the
SQL statement. */
set_bind_variables();
/* Open the cursor and execute the statement.
* If the statement is not a query (SELECT), the
* statement processing is completed after the
* OPEN.
EXEC SQL OPEN C USING DESCRIPTOR bind_dp;
/* Call the function that processes the select-list.
* If the statement is not a query, this function
* just returns, doing nothing.
process_select_list();
/* Tell user how many rows processed. */
for (i = 0; i < 8; i++)
if (strncmp(dyn_statement, dml_commands, 6) == 0)
printf("\n\n%d row%c processed.\n", sqlca.sqlerrd[2], sqlca.sqlerrd[2] == 1 ? '\0' : 's');
break;
/* Close the cursor. */
EXEC SQL CLOSE C;
/* When done, free the memory allocated for pointers in the bind and
select descriptors. */
for (i = 0; i < MAX_ITEMS; i++)
if (bind_dp->V != (char *) 0)
free(bind_dp->V);
free(bind_dp->I); /* MAX_ITEMS were allocated. */
if (select_dp->V != (char *) 0)
free(select_dp->V);
free(select_dp->I); /* MAX_ITEMS were allocated. */
/* Free space used by the descriptors themselves. */
SQLSQLDAFree(ctx, bind_dp);
SQLSQLDAFree(ctx, select_dp);
} /* end of for(;;) statement-processing loop */
disconnect_database();
EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL COMMIT WORK RELEASE;
puts("\nHave a good day!\n");
return;
* Allocate the BIND and SELECT descriptors using sqlald().
* Also allocate the pointers to indicator variables
* in each descriptor. The pointers to the actual bind
* variables and the select-list items are realloc'ed in
* the set_bind_variables() or process_select_list()
* routines. This routine allocates 1 byte for select_dp->V
* and bind_dp->V, so the realloc will work correctly.
alloc_descriptors(size, max_vname_len, max_iname_len)
int size;
int max_vname_len;
int max_iname_len;
int i;
* The first sqlald parameter determines the maximum number of
* array elements in each variable in the descriptor. In
* other words, it determines the maximum number of bind
* variables or select-list items in the SQL statement.
* The second parameter determines the maximum length of
* strings used to hold the names of select-list items
* or placeholders. The maximum length of column
* names in ORACLE is 30, but you can allocate more or less
* as needed.
* The third parameter determines the maximum length of
* strings used to hold the names of any indicator
* variables. To follow ORACLE standards, the maximum
* length of these should be 30. But, you can allocate
* more or less as needed.
if ((bind_dp =
SQLSQLDAAlloc(ctx, size, max_vname_len, max_iname_len)) ==
(SQLDA *) 0)
fprintf(stderr,
"Cannot allocate memory for bind descriptor.");
return -1; /* Have to exit in this case. */
if ((select_dp =
SQLSQLDAAlloc(ctx, size, max_vname_len, max_iname_len)) == (SQLDA *)
0)
fprintf(stderr,
"Cannot allocate memory for select descriptor.");
return -1;
select_dp->N = MAX_ITEMS;
/* Allocate the pointers to the indicator variables, and the
actual data. */
for (i = 0; i < MAX_ITEMS; i++) {
bind_dp->I = (short *) malloc(sizeof (short));
select_dp->I = (short *) malloc(sizeof(short));
bind_dp->V = (char *) malloc(1);
select_dp->V = (char *) malloc(1);
return 0;
int get_dyn_statement()
char *cp, linebuf[256];
int iter, plsql;
for (plsql = 0, iter = 1; ;)
if (iter == 1)
printf("\nSQL> ");
dyn_statement[0] = '\0';
fgets(linebuf, sizeof linebuf, stdin);
cp = strrchr(linebuf, '\n');
if (cp && cp != linebuf)
*cp = ' ';
else if (cp == linebuf)
continue;
if ((strncmp(linebuf, "EXIT", 4) == 0) ||
(strncmp(linebuf, "exit", 4) == 0))
return -1;
else if (linebuf[0] == '?' ||
(strncmp(linebuf, "HELP", 4) == 0) ||
(strncmp(linebuf, "help", 4) == 0))
help();
iter = 1;
continue;
if (strstr(linebuf, "BEGIN") ||
(strstr(linebuf, "begin")))
plsql = 1;
strcat(dyn_statement, linebuf);
if ((plsql && (cp = strrchr(dyn_statement, '/'))) ||
(!plsql && (cp = strrchr(dyn_statement, ';'))))
*cp = '\0';
break;
else
iter++;
printf("%3d ", iter);
return 0;
void set_bind_variables()
int i, n;
char bind_var[64];
/* Describe any bind variables (input host variables) */
EXEC SQL WHENEVER SQLERROR DO sql_error();
bind_dp->N = MAX_ITEMS; /* Initialize count of array elements. */
EXEC SQL DESCRIBE BIND VARIABLES FOR S INTO bind_dp;
/* If F is negative, there were more bind variables
than originally allocated by sqlald(). */
if (bind_dp->F < 0)
printf ("\nToo many bind variables (%d), maximum is %d\n.",
-bind_dp->F, MAX_ITEMS);
return;
/* Set the maximum number of array elements in the
descriptor to the number found. */
bind_dp->N = bind_dp->F;
/* Get the value of each bind variable as a
* character string.
* C contains the length of the bind variable
* name used in the SQL statement.
* S contains the actual name of the bind variable
* used in the SQL statement.
* L will contain the length of the data value
* entered.
* V will contain the address of the data value
* entered.
* T is always set to 1 because in this sample program
* data values for all bind variables are entered
* as character strings.
* ORACLE converts to the table value from CHAR.
* I will point to the indicator value, which is
* set to -1 when the bind variable value is "null".
for (i = 0; i < bind_dp->F; i++)
printf ("\nEnter value for bind variable %.*s: ",
(int)bind_dp->C, bind_dp->S);
fgets(bind_var, sizeof bind_var, stdin);
/* Get length and remove the new line character. */
n = strlen(bind_var) - 1;
/* Set it in the descriptor. */
bind_dp->L = n;
/* (re-)allocate the buffer for the value.
sqlald() reserves a pointer location for
V but does not allocate the full space for
the pointer. */
bind_dp->V = (char *) realloc(bind_dp->V, (bind_dp->L + 1));
/* And copy it in. */
strncpy(bind_dp->V, bind_var, n);
/* Set the indicator variable's value. */
if ((strncmp(bind_dp->V, "NULL", 4) == 0) ||
(strncmp(bind_dp->V, "null", 4) == 0))
*bind_dp->I = -1;
else
*bind_dp->I = 0;
/* Set the bind datatype to 1 for CHAR. */
bind_dp->T = 1;
return;
void process_select_list()
int i, null_ok, precision, scale;
if ((strncmp(dyn_statement, "SELECT", 6) != 0) &&
(strncmp(dyn_statement, "select", 6) != 0))
select_dp->F = 0;
return;
/* If the SQL statement is a SELECT, describe the
select-list items. The DESCRIBE function returns
their names, datatypes, lengths (including precision
and scale), and NULL/NOT NULL statuses. */
select_dp->N = MAX_ITEMS;
EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;
/* If F is negative, there were more select-list
items than originally allocated by sqlald(). */
if (select_dp->F < 0)
printf ("\nToo many select-list items (%d), maximum is %d\n",
-(select_dp->F), MAX_ITEMS);
return;
/* Set the maximum number of array elements in the
descriptor to the number found. */
select_dp->N = select_dp->F;
/* Allocate storage for each select-list item.
sqlprc() is used to extract precision and scale
from the length (select_dp->L).
sqlnul() is used to reset the high-order bit of
the datatype and to check whether the column
is NOT NULL.
CHAR datatypes have length, but zero precision and
scale. The length is defined at CREATE time.
NUMBER datatypes have precision and scale only if
defined at CREATE time. If the column
definition was just NUMBER, the precision
and scale are zero, and you must allocate
the required maximum length.
DATE datatypes return a length of 7 if the default
format is used. This should be increased to
9 to store the actual date character string.
If you use the TO_CHAR function, the maximum
length could be 75, but will probably be less
(you can see the effects of this in SQL*Plus).
ROWID datatype always returns a fixed length of 18 if
coerced to CHAR.
LONG and
LONG RAW datatypes return a length of 0 (zero),
so you need to set a maximum. In this example,
it is 240 characters.
printf ("\n");
for (i = 0; i < select_dp->F; i++)
char title[MAX_VNAME_LEN];
/* Turn off high-order bit of datatype (in this example,
it does not matter if the column is NOT NULL). */
sqlnul ((unsigned short *)&(select_dp->T), (unsigned short
*)&(select_dp->T), &null_ok);
switch (select_dp->T)
case 1 : /* CHAR datatype: no change in length
needed, except possibly for TO_CHAR
conversions (not handled here). */
break;
case 2 : /* NUMBER datatype: use sqlprc() to
extract precision and scale. */
sqlprc ((unsigned int *)&(select_dp->L), &precision,
&scale);
/* Allow for maximum size of NUMBER. */
if (precision == 0) precision = 40;
/* Also allow for decimal point and
possible sign. */
/* convert NUMBER datatype to FLOAT if scale > 0,
INT otherwise. */
if (scale > 0)
select_dp->L = sizeof(float);
else
select_dp->L = sizeof(int);
break;
case 8 : /* LONG datatype */
select_dp->L = 240;
break;
case 11 : /* ROWID datatype */
case 104 : /* Universal ROWID datatype */
select_dp->L = 18;
break;
case 12 : /* DATE datatype */
select_dp->L = 9;
break;
case 23 : /* RAW datatype */
break;
case 24 : /* LONG RAW datatype */
select_dp->L = 240;
break;
/* Allocate space for the select-list data values.
sqlald() reserves a pointer location for
V but does not allocate the full space for
the pointer. */
if (select_dp->T != 2)
select_dp->V = (char *) realloc(select_dp->V,
select_dp->L + 1);
else
select_dp->V = (char *) realloc(select_dp->V,
select_dp->L);
/* Print column headings, right-justifying number
column headings. */
/* Copy to temporary buffer in case name is null-terminated */
memset(title, ' ', MAX_VNAME_LEN);
strncpy(title, select_dp->S, select_dp->C);
if (select_dp->T == 2)
if (scale > 0)
printf ("%.*s ", select_dp->L+3, title);
else
printf ("%.*s ", select_dp->L, title);
else
printf("%-.*s ", select_dp->L, title);
/* Coerce ALL datatypes except for LONG RAW and NUMBER to
character. */
if (select_dp->T != 24 && select_dp->T != 2)
select_dp->T = 1;
/* Coerce the datatypes of NUMBERs to float or int depending on
the scale. */
if (select_dp->T == 2)
if (scale > 0)
select_dp->T = 4; /* float */
else
select_dp->T = 3; /* int */
printf ("\n\n");
/* FETCH each row selected and print the column values. */
EXEC SQL WHENEVER NOT FOUND GOTO end_select_loop;
for (;;)
EXEC SQL FETCH C USING DESCRIPTOR select_dp;
/* Since each variable returned has been coerced to a
character string, int, or float very little processing
is required here. This routine just prints out the
values on the terminal. */
for (i = 0; i < select_dp->F; i++)
if (*select_dp->I < 0)
if (select_dp->T == 4)
printf ("%-*c ",(int)select_dp->L+3, ' ');
else
printf ("%-*c ",(int)select_dp->L, ' ');
else
if (select_dp->T == 3) /* int datatype */
printf ("%*d ", (int)select_dp->L,
*(int *)select_dp->V);
else if (select_dp->T == 4) /* float datatype */
printf ("%*.2f ", (int)select_dp->L,
*(float *)select_dp->V);
else /* character string */
printf ("%-*.*s ", (int)select_dp->L,
(int)select_dp->L, select_dp->V);
printf ("\n");
end_select_loop:
return;
void help()
puts("\n\nEnter a SQL statement or a PL/SQL block at the SQL> prompt.");
puts("Statements can be continued over several lines, except");
puts("within string literals.");
puts("Terminate a SQL statement with a semicolon.");
puts("Terminate a PL/SQL block (which can contain embedded
semicolons)");
puts("with a slash (/).");
puts("Typing \"exit\" (no semicolon needed) exits the program.");
puts("You typed \"?\" or \"help\" to get this message.\n\n");
int connect_database()
err_sql = SQL_SUCC;
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
EXEC SQL CONTEXT ALLOCATE :ctx;
EXEC SQL CONTEXT USE :ctx;
EXEC SQL CONNECT :db_uid;
if(err_sql != SQL_SUCC){
printf("err => connect database(ctx:%ld, uid:%s) failed!\n", ctx, db_uid);
return -1;
return 1;
int disconnect_database()
err_sql = SQL_SUCC;
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
EXEC SQL CONTEXT USE :ctx;
EXEC SQL COMMIT WORK RELEASE;
EXEC SQL CONTEXT FREE:ctx;
return 1;
void sql_error()
printf("err => %.*s", sqlca.sqlerrm.sqlerrml, sqlca.sqlerrm.sqlerrmc);
printf("in \"%.*s...\'\n", oraca.orastxt.orastxtl, oraca.orastxt.orastxtc);
printf("on line %d of %.*s.\n\n", oraca.oraslnr, oraca.orasfnm.orasfnml,
oraca.orasfnm.orasfnmc);
switch(sqlca.sqlcode) {
case -1: /* unique constraint violated */
err_sql = SQL_UNIQUE;
break;
case -1012: /* not logged on */
case -1089:
case -3133:
case -1041:
case -3114:
case -3113:
/* �6�Ŭ�� shutdown�ǰų� �α��� ���°� �ƴҶ� ��b�� �õ� */
/* immediate shutdown in progress - no operations are permitted */
/* end-of-file on communication channel */
/* internal error. hostdef extension doesn't exist */
err_sql = SQL_DISCONNECT;
break;
case -1400:
err_sql = SQL_NOTNULL;
break;
default:
err_sql = SQL_ERR;
break;
EXEC SQL CONTEXT USE :ctx;
EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL ROLLBACK WORK;
void sql_not_found()
err_sql = SQL_NOTFOUND;Hi Jane,
What version of Berkeley DB XML are you using?
What is your operating system and your hardware platform?
For how long have been the application running?
What is your current container size?
What's set for EnvironmentConfig.setThreaded?
Do you know if containers have previously not been closed correctly?
Can you please post the entire error output?
What's the JDK version, 1.4 or 1.5?
Thanks,
Bogdan -
Help needed in writing installers for swing application
Hi ,
I want to write an installer for one of our home grown profiler tool. I need to write the installer for different platforms such as windows,linux,solaris,HP-UX.
Does anybody have any idea of how to go ahead in writing installations. Share if there is any good links such as tutorials as well is thr any opensource tool (similar to installsheild) to write installers . As well following is the tentative algorithm for my install sheild
1. Create a home dir for the tool and put all the application files in tht.
2. Installing a 3rd party jar and make a home for it.
3. Option for user to select the features(i hv 2 features. user can either select both or select individual feature) to be installed.
4. Select the appserver home if any. On selection i hv to update the classpath in the startup batch file for the application(This is the toughest step i beleive bcoz each appserver have different folder structures and different startup batch files).Tried obtaining the output using SQL and the result is as follows:
SQL> WITH T AS
2 (
3 SELECT 1 COL1 FROM DUAL
4 UNION
5 SELECT 2 COL1 FROM DUAL
6 UNION
7 SELECT 3 COL1 FROM DUAL
8 UNION
9 SELECT 4 COL1 FROM DUAL
10 UNION
11 SELECT 5 COL1 FROM DUAL
12 UNION
13 SELECT 8 COL1 FROM DUAL
14 UNION
15 SELECT 9 COL1 FROM DUAL
16 UNION
17 SELECT 10 COL1 FROM DUAL
18 UNION
19 SELECT 13 COL1 FROM DUAL
20 UNION
21 SELECT 14 COL1 FROM DUAL
22 UNION
23 SELECT 15 COL1 FROM DUAL
24 UNION
25 SELECT 16 COL1 FROM DUAL
26 UNION
27 SELECT 23 COL1 FROM DUAL
28 UNION
29 SELECT 24 COL1 FROM DUAL
30 )
31 SELECT OUTPUT FROM
32 (
33 SELECT DECODE(COL3,NULL,COL1, COL2) || '-' || LEAD(DECODE(COL3,NULL,COL3, COL1)) OVER (ORDER BY DECODE(COL3,NULL,COL1, COL2)) OUTPUT FROM
34 (
35 SELECT COL1, LEAD(COL1) OVER (ORDER BY COL1) COL2, LAG(COL1) OVER (ORDER BY COL1) COL3 FROM T
36 )
37 WHERE
38 (COL2 - COL1 > 1 OR COL2 IS NULL OR COL3 IS NULL)
39 )
40 WHERE OUTPUT != '-';
OUTPUT
1-5
8-10
13-16
23-24
Maybe you are looking for
-
UK payroll - Maternity leave issue
Hi Experts, I am facing an issue with UK maternity levae. Employee is on leave from 16th of this month and there are 18 working days in this month. so employee should be paid for 8 days which she has worked. But in system it is getting paid for 10 da
-
Acrobat X Pro transfert from MacBook Pro to iMac
In January 2012 I bought Adobe Acrobat X Pro for Mac online. I immediately downloaded and installed it on my 17" MacBook Pro (early 2009). In December 2013 I bought an iMac and until recently I used concurrently both computers. When I stopped using t
-
At windows start up it tells me that this copy of window is not genuine and as get into window a message pops up telling that fine the solution qlick here and this tells me is firefox and the steps I need to take. But nothing works even taking the cu
-
I need some help guys, I have a BB 8320 Vodafone which was from the UK and the person that I took it from unlocked the phone and passed it on to me now. I have a few issues with the BBM service. I have recently activated my BBM service by choosing a
-
Address book resets birthdates to july
I have problems with birthdates. If I set the birthdate of an entry, move to another entry and go back to that first entry, the birthdate is set to july no matter what was the original month. The day and year remains intact, only the month resets. I