Creating new Connections/Statements/ResultSets
Hi,
RDMS = Sybase
JDBC = Jconnect 5.5 obtained from Sybase website
Purpose:
To loop through the program below with different queries and produce
a resultset.
Details:
I have a program that creates a query stores it in a static setter.
The program calls the program below. The program below:
(1) obtains the query from a static getter
(2) creates a connection/statement/resultset
(3) returns to the calling program where
(a) resultset is displayed
(b) calls close() in the program below which closes the
connection/statement/resultset
Problem:
I thought that creating a new connection/statement/resultset
each time the program below is called would work.
The program below returns the correct resultset for the first query
but when called with a different query returns the first resultset that
was generated.
Question:
Do I have to use different objects for the connection/statement/resultset each time the program is called
even though the existing connection/statement/resultset is closed
before a new connection/statement/resultset is created ?
if yes,
I don't how to change the object for connection/statement/resultset
dynamically each time the program below is called.
Any assistance provided would be greatly appreciated !!
Thanks for your time,
YAM-SSM
package ecmutl;
import java.awt.*;
import java.sql.*;
public class DbConnect implements Runnable {
public static Thread queryThread = null;
public static Font fntF;
public static Connection conn = null;
public static ResultSet rs = null;
public static Statement stmt = null;
public static String nodename = EcmUtlLogicals.getNodeName();
public static String password = EcmUtlLogicals.getPassword();
public String newline = "\n";
public static String sqlstate;
public static String message;
public static String queryThreadDone = "false";
public static String query = EcmUtlLogicals.getQuery();
public static String dbname = EcmUtlLogicals.dbname;
public static String username = EcmUtlLogicals.username;
public static int SybaseReturnCode;
void Connect() {
try {
Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
conn = DriverManager.getConnection("jdbc:sybase:Tds:"+nodename+"/"+dbname,username,password);
catch (SQLException exc) {
sqlstate = exc.getSQLState();
message = exc.getMessage();
SybaseReturnCode = exc.getErrorCode();
catch (InstantiationException iste) {
catch (ClassNotFoundException cnfe) {
catch (IllegalAccessException iae) {
if (queryThread == null) {
queryThread = new Thread(this, "Query");
queryThread.start();
} // close if
} // close Connect method
public void run() {
try {
stmt = DbConnect.conn.createStatement();
rs = stmt.executeQuery(query);
queryThread = null;
} // close try
catch (SQLException sqlex) {
sqlstate = sqlex.getSQLState();
message = sqlex.getMessage();
SybaseReturnCode = sqlex.getErrorCode();
queryThread = null;
} // close catch
catch (java.lang.Exception ex) {
ex.printStackTrace ();
} // close catch
queryThreadDone = "true";
} // close run method
static void close() {
try {
if ( rs != null){
rs.close();
if ( stmt != null){
stmt.close();
if ( conn != null){
conn.close();
} // close try
catch (SQLException error){
}// close close()
} // close DbConnect class
Then I'd say you should write a QueryThread object
that extends Thread and takes an SQL statement in its
constructor. In the run method, create a connection,
statement, and result set to run that query, close
them in reverse order when you're done, and provide a
getter to give access to the results. Don't return a
reference to the result set; put the results in a data
structure or CachedRowSet and close out the result set
as soon as you're done with it. ResultSets are
database cursors, which are scarce resources.
With this design, every thread has its own connection
and resources. They can't conflict with each other. -
MODHi MOD,
I finished coding a QueryThread object exactly as you instructed
and IT WORKS !!!!! The calling program calls QueryThread by:
QueryThread qt = new QueryThread(query);
qt.start();
QueryThread code:
package ecmutl;
import java.awt.*;
import java.sql.*;
import java.util.List;
import java.util.*;
public class QueryThread extends Thread {
public static Thread queryThread = null;
public static Font fntF;
public static Connection conn = null;
public static ResultSet rs = null;
public static Statement stmt = null;
public static String nodename = EcmUtlLogicals.getNodeName();
public static String password = EcmUtlLogicals.getPassword();
public String newline = "\n";
public static String sqlstate;
public static String message;
public static String queryThreadDone = "false";
public String query;
public static String dbname = EcmUtlLogicals.dbname;
public static String username = EcmUtlLogicals.username;
public static int SybaseReturnCode;
public QueryThread(String query) {
this.query = query;
public void run() {
try {
Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
conn = DriverManager.getConnection("jdbc:sybase:Tds:"+nodename+"/"+dbname,username,password);
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
List resultSetArray = new LinkedList();
resultSetArray = new ArrayList();
if (rs != null) {
int i;
ResultSetMetaData rsmd = rs.getMetaData ();
int numCols = rsmd.getColumnCount ();
for (i=1; i<=numCols; i++) {
if (i > 1) resultSetArray.add(",");
resultSetArray.add(rsmd.getColumnLabel(i));
resultSetArray.add(newline);
boolean more = rs.next ();
while (more) {
for (i=1; i<=numCols; i++) {
if (i > 1) resultSetArray.add(",");
resultSetArray.add(rs.getString(i));
resultSetArray.add(newline);
more = rs.next ();
EcmUtlLogicals.setResultSetArray(resultSetArray);
if (rs != null){
rs.close();
if (stmt != null) {
stmt.close();
if (conn != null) {
conn.close();
queryThread = null;
catch (SQLException sqlex) {
sqlstate = sqlex.getSQLState();
message = sqlex.getMessage();
SybaseReturnCode = sqlex.getErrorCode();
queryThread = null;
catch (java.lang.Exception ex) {
ex.printStackTrace ();
queryThreadDone = "true";
}I have only be using Java for three months. Sometimes one needs a teacher to go along with the APIs.
Thanks for your patience/help/time
YAM-SSM
Similar Messages
-
SBO0001 error DBD:ORA12154 error while creating new connection
Dear All,
I have installed XIR3 on a windows 64 bit with oracle 10g R2 client.
The CMS is up and running and I am able to connect to the infoview and view the lsit of all the migrated objects from BOXIR2.
But, when I am trying to create a new connection for the universe or trying to execute the existing reports i am getting the following error.
(i.e I guess BO is unable to connect to DB)
*SBO0001 error DBD:ORA12154 error while creating new connection
I tried various solution from BOB but still could not solve this. Please anyone suggest few tips regarding this case
Business objects: CMS is running and able to connect to infoview and able to log on to CMC
Database client: Able to log on to DB using sqlplus and tnsping is working.
the details of the software are as follows
*BO Server configuration
OS: Windows Server 2008 R2 64 bit
Business Objects XI R3 3.0
Oracle client 10gR2 32 bit
*Database server configuration
Oracle 11g R2 64 bit
Thanks,
MikeMike :
I am having a similar issue with the BOE and Oracle.
Can you please provide details of which Oracle client you ended-up using..?
32-bit or 64-bit...?
Oracle client version...?
Specific client patches applied..?
Thanks,
Mark -
Everytime when i connect 3g internet with my laptop using USB (Windows 7) it creats new connection trailing network1, network2, network3.........
It does not recognise my old connection.
Same case with wifi connection as well.
Also after updating new IOS-5, whenever i make USB connection it does not display my name under my computer.
But before it use to display my name now it is coming as Apple I-phone.
Anyone who can help on this, how to get it resolved.
- I have update my phone with backup (OLD version of IOS) but issue still presists.
This is the same issue somone mention on below.
http://www.sevenforums.com/network-sharing/193123-iphone-network-location-doesnt -save-when-disconnected.html
Kind Regards
@ru..If the message that is displaying is "Network connection timed out", disable any Anti-Virus or Firewall software on the comptuer or check with the company that supports the product on how to modify it to allow iTunes to connect to the Internet.
-
How to create new connection in directory service manager
Hello,
I have upgraded OID from 10.1.4.3 to 11.1.1.6. after upgrade i used below url to connect directory service manager.
http://hosname:7005/odsm
trying to create new connection but not able to connect getting below error
"Bind Failed. Host='dog1044' Details : dog1044:3060"
using below value while creating new connection
select OID
Name : 11goid
server : oidserver01
port : 3060
username : cn=orcladmin
Thanks
Karthick KKarthick,
Or try to bind it from your ODSM server, eg: ldapbind -h oidserver01 -p 3060 -D "cn=orcladmin" -w xpto
I hope this helps,
Thiago Leoncil. -
CR closes when using "create new connection"
Hi,
Crystal Reports 2008.
After opening a CR 10 report once, I can't create new blank reports. If I use "create new connection" to add a data source the program shuts down. No crash dump or anything.
Helpdesk could reproduce error but couldn't solve the problem.
To re-install my system after format costs a lot of time (and therefore money). So I want to try to solve my problem first by my self.
Question: does freeware software exist to trace the behavior of an EXE file?
I'd like to figure out where it goes wrong.
Manually removing CR and reinstalling didn't help either. Nothing helps. FP 1.7 installed. Still the same problem..Please re-post if this is still an issue or purchase a case and have a dedicated support
engineer work with your directly.
Try updating the .NET Framework -
Bug - unable to create new connections on SQL Developer 4.0.0.13
Upgraded to SQL Developer 4.0 and we are unable to create new connections in the Connections pane on the left hand side.
Clciking the green plus button and right clicking Connections and 'New Connection' doesn't bring up the New Database Connection dialog box.Sounds like an 'install' problem.
Can you extract the zip to a new directory and try again? You did extract v4 to a fresh directory, yes? -
Crystal Report 2011 SP4 APPCrash on Create New Connection
Hi Guys!
I've experience a problem with Crystal Reports 2011 for SAP B1 9.0 PL11. CR crashes everytime I create new connection folder.
I'm running Windows 8.1 x64.Hi Pieterjan,
CR 2013 for B1 can be downloaded from Software Download Center : https://websmp106.sap-ag.de/support
Choose SAP Business One from menu "Software Downloads" > expand from left side "SAP Business One Products" > Installations > SAP CRYSTAL REPORTS FOR B1 > CRYSTAL REPORTS 2013 FOR B1
Just keep in mind that, to make CR preview in B1 works fine, please check if correct CR runtime (.NET 32bit or 64bit) is installed. 32bit client will install 32 bit runtime automatically and same for 64 bit.
To make SAP Business One connection and Add ins menu works, please make sure correct version of Integration Package together with correct BOE runtime are installed. Install Integration Package will install BOE runtime automatically. ( We only need 32bit BOE runtime in CR for B1). Of course you can also install them seperately.
We have relevant Note 1815476 to explain this.
Hope this clarifies some points.
Thanks,
Maggie An
SAP Business One Global Support -
Having trouble creating new connection in SQLDeveloper
When I try to create a new connection in SQLDeveloper, I get the following message:
Status : Failure -Test failed: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The username and password are the same as the ones I use to connect to sqlplus, right? I am a complete newb to sql, so I would really appreciate if someone could provide a step-by-step solution.C:\Users\Admin>lsnrctl
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 26-APR-2013 21:00
:01
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1522)))
STATUS of the LISTENER
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Produ
ction
Start Date 26-APR-2013 17:55:47
Uptime 0 days 3 hr. 4 min. 19 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File C:\app\Admin\product\11.2.0\dbhome_2\network\admin\lis
tener.ora
Listener Log File c:\app\admin\diag\tnslsnr\Admin-PC\listener\alert\log.
xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1522ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Admin-PC)(PORT=1522)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl.gateway.2wire.net" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.gateway.2wire.net" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL> service
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1522)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
Service "orcl.gateway.2wire.net" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
Service "orclXDB.gateway.2wire.net" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Handler(s):
"D000" established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER <machine: ADMIN-PC, pid: 4496>
(ADDRESS=(PROTOCOL=tcp)(HOST=Admin-PC)(PORT=49224))
The command completed successfully
LSNRCTL> -
Weblogic creates new connection xhen using dataset
Hi,
I use non JTS datasources in order to access to connectionpool. Each
time I request Weblogic, it recreates new connections. Of course quickly
the max connection number allowed is reached!
I used JTS datasources before and all worked fine!
Can someone help me understanding this?
Thx, Piotok Thx.
Slava Imeshev wrote:
Hi Piot,
There is a hidden bug in your code. Briefly, when you use
jts, it uses the same connection within the transaction.
So when you use non-jts DS, you always get a new connection
from the DS. Nevertheless, the your code should be adjusted to the
following approach:
1. get a connection from a DS
2. use the connection
3. close result sets
4. close [prepared] statements
5. close the connection
Obviously, your code doesn't follow these guidelines.
Regards,
Slava Imeshev
"Piot" <[email protected]> wrote in message
news:[email protected]...
weblogic.jdbc.connectionPool.pool1=\
url=jdbc:inetora:<ip>:1521:<db1>,\
driver=com.inet.ora.OraDriver,\
loginDelaySecs=1,\
initialCapacity=2,\
maxCapacity=10,\
capacityIncrement=1,\
allowShrinking=true,\
shrinkPeriodMins=15,\
refreshTestMinutes=1,\
testTable=T1,\
props=user=User;password=Password\
I use a class PollAccess managing the connection access and release:
public PoolAccess(String poolName) {
InitialContext initCtx = null;
try {
initCtx = new InitialContext();
dataSource = (javax.sql.DataSource) initCtx.lookup(poolName);
catch (NamingException ne) {
System.out.println(ne.toString());
throw new EJBException(ne);
public Connection getConnection() throws SQLException {
// return connection from the DataSource
return dataSource.getConnection();
public void releaseConnection(Statement st) throws SQLException {
try {
if (st != null) {
st.close();
catch (Exception e) {
System.out.println("Error closing Statement: " + e);
try {
if (this.getConnection() != null) {
this.getConnection().close();
catch (Exception e) {
System.out.println("Error closing Connection: " + e);
when requesting :
Statement st=DatabaseAccess.getConnection().createStatement();
ResultSet rs = st.executeQuery(query.toString().toUpperCase());
while (rs.next()) {
some stuff;
rs.close();
DatabaseAccess.releaseConnection(st);
That's all!
Slava Imeshev wrote:
Could you give us definitions of your pools
and code snippets?
Regards,
Slava Imeshev
"Piot" <[email protected]> wrote in message
news:[email protected]...
1) The pool has 10 connection. I only use one connection...
2) that's exactly what I do. After each request I call close().
What is strange is that when I use the same code with JTS it works
fine...
Slava Imeshev wrote:
Hi,
I see two variants here. First, size of your pool is too small to
serve all requests. Second, you don't release connections
borrowed from the pool. All connections which are not used
should be explicitely returned to the pool by calling close();
"Stéphane Piotrowski" <[email protected]> wrote in message
news:[email protected]...
Hi,
I use non JTS datasources in order to access to connectionpool. Each
time I request Weblogic, it recreates new connections. Of course
quickly
the max connection number allowed is reached!
I used JTS datasources before and all worked fine!
Can someone help me understanding this?
Thx, Piot -
Switching ABAP debugger on/off without creating new connection
Is it possible to switch the ABAP debugger on/off without creating a new connection? It seems that the only way to enable the debugger is when the connection is first opened.
Hello,
No, it is not possible.
However, if you have SAP release 620 or higher, you can use a new ABAP debugging variant, so-called "external debugging", to debug RFC/HTTP(SOAP) calls even without setting debugging option in connection string.
You can enable "external debugging" in SE37 by selecting
Utilities->Settings->Debugging->Activate external...
For details about "external debugging", please refer to ABAP workbench documentation.
Regards,
Guangwei -
Step 20 - Create new connection for NORTHWIND user, Northwind - Migrated
Hello,
I am migrating the Northwind database from Access to Oracle, and I am following the directions, but when I get to step 20, create a new connection for the Northwind User, Northwind - Migrated, I cannot create the connection. After running the converted model script that was generated by the workbench -- I don't see the Northwind - Migrated database. So how can I create a connection to it?
Also -- after I ran the script, I did not see any messages in the log showing I ran the script, but the status bar at the bottom of the tool said script finished..... I am confused.
Thanks!
JeffAnyone have this same issue trying to migrate the Northwind database to access using migration workbench?
Thanks so much,
Jeff -
CRXI Shuts down when clicking on Create New Connection
I have been working with both Crystal 8.5 and XI on my system together for a couple of years and have had no problems. I've been working primarily in 8.5 for the last several months and only needed to view a few reports in XI (without problem). Now I am trying to create a new connection in XI (version 11.0.0.1282) and it shuts down the Designer completely without any error message. I can't find the old knowledgebase that used to be on the Crystal Decisions website so I thought I would post here to see if anyone has heard of this issue.
Other mitigating factors may include VS2008 Pro installed on system in the last few months but since then I have created a new report in XI and 8.5 and run them in VB2008 with the Report Viewer as a test of a new program I want to build. That was just before Christmas.
I am probably going to have to reinstall but I am not sure if I have the latest version updates here. Is the above version the latest? And if not, where can I download the updates?
TIA rasincNTDLL!RTLDISPATCHEXCEPTION9In crw32__PID__5876__Date__01_11_2010__Time_10_50_54PM__360__Second_Chance_Exception_C0000005.dmp the assembly instruction at ntdll!RtlDispatchException9 in C:WINDOWSsystem32
tdll.dll from Microsoft Corporation has caused an access violation exception (0xC0000005) when trying to write to memory location 0x00030ffc on thread 0
Module Information
Image Name: C:WINDOWSsystem32
tdll.dll Symbol Type: PDB
Base address: 0x7c900000 Time Stamp: Wed Aug 04 03:56:36 2004
Checksum: 0x000af2f7 Comments:
COM DLL: False Company Name: Microsoft Corporation
ISAPIExtension: False File Description: NT Layer DLL
ISAPIFilter: False File Version: 5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)
Managed DLL: False Internal Name: ntdll.dll
VB DLL: False Legal Copyright: © Microsoft Corporation. All rights reserved.
Loaded Image Name: ntdll.dll Legal Trademarks:
Mapped Image Name: Original filename: ntdll.dll
Module name: ntdll Private Build:
Single Threaded: False Product Name: Microsoft® Windows® Operating System
Module Size: 704.00 KBytes Product Version: 5.1.2600.2180
Symbol File Name: c:symcache
tdll.pdb36515FB5D04345E491F672FA2E2878C02
tdll.pdb Special Build: & -
Question about SAP client setting when create new connection in CR2008
Dear All,
I have a question about SAP client setting in Crystal Report 2008 when I try to create a new connection use SAP OpenSQL(SAP Table,Cluster,or Function).
I have a SAP IDES environment with 5 clients.
While I try to create a CR standard report use SAP OpenSQL, I entered 800 into Client field in u201CUser logon credentialsu201D. The connection can be created and I can get table list. After I built a report ,I can not get data from IDES client 800, but I can get data from client 000.
I am sure client 800 has data.I checked client 800 table with Tcord se16.
I also did other tests and felt confused a lot.
Even inexistent client, such as u201C00u201Dand u201C8000u201D can be used for creating connection.
I just want to know how can I get data from client 800.
Thanks for your kindly help!
WayneDear Ingo,
Thanks for your reply!
I am not sure about your suggestion clearly. What's your mean all the authorizations to use CR?
Maybe I should clarify my operations.
I logon CR2008 as administrator and created two SAP connections with different client.
There is a table named "/BEV3/CHBALLG" be showed in these connections.
I checked clients "000" and "800" both have data in the table.
I can use client 000 connection create report and get right data, but the report base on client 800 connection could not get data.
If change to another table,such as "/SAPDMC/LSOFIL", I can get data both form these connections.
I found one thing is very weird. Client "00" and "8000" do not exist in my IDES environment, but I can use them for creating connection.
May I have your further suggestions?
Wayne -
SAPGUI Java 7.20 Rev 1 for Mac - unable to create new connections
Greetings,
I am on Snow Leopard, I just installed SAPGUI 7.20 Rev 1. When I try to create a new connection, the "System" tab has a Red X and I am unable to type anything into it.
Also, when I change the Description, the "Save" and "Save As" buttons are still greyed out and I am unable to click them.
I tried going through the documentation and made sure that I have Apple's latest Java updates etc.
Obviously I am doing something wrong somewhere. If someone will point me in the right direction I would be much obliged.
Thank you and cheers
MohanHello,
you might want to read chapters "7. Administration" and "9.1 Connection Strings" of the manual coming with the SAP GUI for Java installation.
In case you want to reuse the configuration of SAP GUI for Windows, there are conversion scripts available on the [SAP GUI family page|SAP GUI Family] or directly [here|SAP GUI Family?rid=/library/uuid/c00de625-24e8-2d10-67b3-f79dad1a27c7].
Best regards
Rolf-Martin
P.S. The latest version currently available is SAP GUI for Java 7.20 rev 5 -
How do I limit the user creat new connect when CPU idle 5%?
my oracle database is 9.2.0.7,
I want to limited the new connection by created when the server (sun solars 5.9) cpu idle <5 % ?> I want to limited the new connection by created when the server (sun solars 5.9) cpu idle <5 % ?
This makes absolutely no sense at all. Not even borderline idiotic - it has invaded the land of idiots looking to conquer and become the biggest one of them all. :-)
But there is actually a very easy way to do it. Outside the database in a script, run uptime. It provides the system load averages for the past 1, 5, and 15 minutes. Use awk to extract these load numbers and use that to make the decision whether connectivity can be allowed or must be denied.
Next check if the Oracle Listener is up. If up and connectivity must be denied, shut it down. If down and connectivity must be allowed, start it. Else, leave it as is.
Then sleep for a few minutes and repeat.
To make this into a proper daemon, you can simply add it to /etc/inittab and have the kernel running it for you and respawning it when it runs into a problem and dies.
Maybe you are looking for
-
Password for oc4jadmin is not being set for silent install.
Application Server 10.1.3 for Windows I have recorded a silent install response file. I have added the following line in order to set the password of the oc4jadmin account, but it does not appear to work because I get an invalid username/password whe
-
Iphoto deleted some pictures from both iphone and iphoto.
I marked some photos to import to iphoto. Iphoto asked if I wanted to delete these photos from iphone and i klicked yes. Iphoto then deleted all of my photos from my iphone. I cannot find that itunes has made a copy before either. what do i do?
-
No blending options in layers.
I recently upped my opinion of Illustrator and was really impressed with how I could change the appearance in the layers panel. Now unable to find it. Using a mac and CS5.5 when selecting drop down button it is not there any more. Layer options only
-
Multiprovider Mapping Issue # Values in the query output
Q . I am getting # values for the free chars and no values for some of the KPIs I have created this report on top of a multiprovider which has a huge number of cubes ( exceeding 10 ) , four DSOs and a couple of infosets , and the query which i am cre
-
How to make it so mail doesn't delete messages
I have my yahoo account attached to the apple account and I want to make it so that the messages are just kept forever. Any idea how? Thanks