Urgent help (on oracle connection pool)

Hi ,
I downloade oracle 8i thin drivers and i am using conenction pool in my application ...
I executed that servlet program
When i try to get conneciton using getDatabaseConnection() method in my jsp i am getting new connection each time ...............
In the oracel doc i read some thing like logical connections and physical connections .............
In my code i set maxLimit to 3 and i am getting connections more than 3 ( all are different).................
When i refresh the browser i am getting different connections like:
con======oracle.jdbc.driver.OracleConnection@338576
con======oracle.jdbc.driver.OracleConnection@1691dec
con======oracle.jdbc.driver.OracleConnection@63ceb4
con======oracle.jdbc.driver.OracleConnection@1590f50
con======oracle.jdbc.driver.OracleConnection@aeff82
con======oracle.jdbc.driver.OracleConnection@906e5b
con======oracle.jdbc.driver.OracleConnection@2403cf
con======oracle.jdbc.driver.OracleConnection@17ab157
See i set max limit as 3 and i got more than 3 connections and each diff ................
What is wrong in my code ............
Please help to me ..........
Here is the code :
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import oracle.jdbc.driver.*;
import oracle.jdbc.pool.*;
public class PoolJdbc4 extends HttpServlet{
private OracleConnectionPoolDataSource ocpds;
private OracleConnectionCacheImpl ods;
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
ocpds =new OracleConnectionPoolDataSource();
ocpds.setURL("jdbc:oracle:xxxxxxxxx");
// ocpds.setUser("xxx");
// ocpds.setPassword("xxx");
// Associate it with the Cache
ods = new OracleConnectionCacheImpl(ocpds);
// Set the Max Limit
ods.setMaxLimit (3);
// Set the Scheme
ods.setCacheScheme (OracleConnectionCacheImpl.FIXED_RETURN_NULL_SCHEME);
catch (Exception e) {
throw new UnavailableException(this, "Couldn't create connection pool");
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
Connection con = null;
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
out.println("Updating salary");
try {
con = ods.getConnection("xxxxx","xxx");
System.out.println("con======="+con);
// Turn on transactions
con.setAutoCommit(false);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from checkout_checkin");
while(rs.next())
out.println(rs.getString(1)+"<br>");
stmt.close();
rs.close();
con.close();
catch (Exception e) {
// Any error is grounds for rollback
try {
con.rollback();
catch (Exception ignored) { }
out.println("No more connections available, try later");
}

ketan reddy - I'm pretty sure you are not getting a new connection each time even though you are seeing a different connection identifier printed each time you get a new connection.
If you have system privs, try looking at v$session while your servlet is running. I think you will see that you only have a single connection and it is being used each time.
For another test, try commenting out your conn.close() call so that you do not free up connections. Your servlet should fail after 3 executions cause it will not be able to get any more connections - because you specified
ods.setMaxLimit (3);
ods.setCacheScheme (OracleConnectionCacheImpl.FIXED_RETURN_NULL_SCHEME);
Good Luck
tim

Similar Messages

  • Help with Oracle Connection Pooling

    Hi,
    I want to create a connection pool that can be accessible in any jsp and in any class of my web application. Is it a good idea to create a class with a static member of type OracleDataSource or any class that handles connections?

    Rafa,
    In order to use JSP, you usually need an application server.
    Oracle's application server already has connection pooling built in.
    No need to re-invent the wheel.
    (In fact most application servers provide database connection pooling.)
    Good Luck,
    Avi.

  • Oracle Connection Pool failure in COM+

    I am having some trouble trying to get a specific database to work with an application that makes use of a COM+ Application. When we point the application at the UAT database everything seems fine, but when we point it to the production database after a few successful calls it ends up failing at the COM+ application recycles. The event viewer provides the following information:
    Event Type:     Error
    Event Source:     COM+
    Event Category:     Unknown
    Event ID:     4786
    Date:          8/5/2007
    Time:          12:54:46 PM
    User:          N/A
    Computer:     APPL_SERVER
    Description:
    The system has called a custom component and that component has failed and generated an exception. This indicates a problem with the custom component. Notify the developer of this component that a failure has occurred and provide them with the information below.
    Component Prog ID: Oracle Connection Pool - tnsnames_alias
    Method Name: IDispenserDriver::CreateResource
    Server Application ID: {30A93CB3-25EB-4258-8C88-5AE103B7B86F}
    Server Application Instance ID:
    {A57C513E-519F-45BD-B46D-DC54B285F534}
    Server Application Name: COM+ Application Name
    The serious nature of this error has caused the process to terminate.
    Exception: C0000005
    Address: 0x7C8327F9
    Call Stack:
    + 0x7c8327f9
    ntdll!RtlFindActivationContextSectionGuid + 0x7d2
    ntdll!RtlInitializeSListHead + 0x175
    ntdll!RtlFindActivationContextSectionGuid + 0x1b7
    msvcrt!malloc + 0x6c
    oracommon9!sktsfMalloc + 0x14
    orageneric9!kpummapg + 0x58
    orageneric9!kghalo + 0xabb
    orageneric9!kghalf + 0x102
    orageneric9!kopo2cpc + 0x61
    orageneric9!kopeini + 0x1d
    orageneric9!kopo2cpc + 0xd2
    orageneric9!kopopgi + 0x117
    OraClient9!koudpnp + 0x712
    OraClient9!koudpnp + 0x101
    OraClient9!kpuinit0 + 0xb19
    OraClient9!kpuinit + 0x38
    OraClient9!OCIEnvInit + 0x1c
    oramts!kpntsrvr::kpntsrvr(class kpntdbid *) + 0x80
    oramts!kpntdbid::allocNewSrvr(struct SIDAND_ATTRIBUTES *) + 0x138
    oramts!kpntdbid::GetSrvr(class kpntsvrl * *,unsigned long) + 0x7df
    oramts!kpntdisp::getNet8conn(class kpntsvrl * *,unsigned long) + 0x41
    oramts!kpntsess::initOCI(void) + 0xec
    oramts!kpntsess::sessionBegin(void) + 0x17b
    oramts!kpntdisp::CreateResource(unsigned long,unsigned long *,long *) + 0xc4
    COMSVCS!DispManGetContext + 0xa3d
    COMSVCS!DispManGetContext + 0x1fee
    oramts!kpntdisp::allocateConnection(class kpntsess * *,unsigned long,class kpntrtyp *) + 0x3c4
    oramts!_kpntsvcgetex + 0x183
    oramts!_kpntsvcget + 0x25
    oramts!kpntctra::getConnectionAndHandles(class kpntrtyp *,struct OCISvcCtx * *,struct OCITrans * *,struct OCIError * *) + 0x87
    oramts!kpntctra::abortBranch(struct xid_t &,class kpntbrnch *,struct BOID *,int,struct BOID *) + 0x15a
    oramts!kpntctra::doAbort(struct BOID *,int,struct BOID *) + 0x454
    oramts!kpntajob::doJob(void) + 0x27
    oramts!kpntjobq::serviceRequest(class kpntjob *) + 0x3e
    oramts!workerThread(void *) + 0xd0
    msvcrt!_endthreadex + 0xa3
    kernel32!GetModuleFileNameA + 0xeb
    Not being an expert in Oracle, I have been able to dig up a little bit of information that might be of use ...
    a) Our tnsnames.ora indicates that the connections are to be DEDICATED and running Toad bares this out -- dllhost ends up with a single connection.
    b) most of the database initial set of parameters seem to be very similar. The only difference I noticed was that the archive log mode and db_cache_advice are ON for production.
    c) We have little control over how the connection strings are being created internally in this COM+ application, but however they are created it works for UAT and doesn't for PROD.
    d) When we go into our web application and hit a page that makes use of the COM+ component to render, it will work the first time but when I do a simple browser refresh it will usually fail on the 2nd or 3rd time. Almost like it is trying to expand the connection pool size and the oracle server is throwing up.
    If I didn't mention earlier the two database instances run on different servers but the application server is exactly the same. We only change the alias we are using for the database (both are defined in tnsnames) and the password used to make its connection.
    Does anyone have any clues on this one? I am really spinning my wheels trying to figure out what could cause this type of situation. Anything at all would be very helpful.

    It appeared to us that the problem was with the Oracle server and that it might have been failing when we were trying to expand our application connection pool size or basically obtain more connections.
    The biggest indicator of this is that we run the same application code against two different databases and one works and one does not work. Having said this, I suppose the problem could be rooted in a data error instead of an oracle server error ...
    Is there a specific trace file on the oracle server that would help me point to any error that is truly an oracle server error? Sorry I am very new to Oracle.

  • Help to Configure Connection Pool For Jdeveloper

    Hi ,
    I am using Jdeveloper 10.1.2 and Oravle AS 10.1.2.
    Language Used : J2EE,Struts and EJB
    I am portletizing struts application.
    I need help to configure Connection pool. By default it is taking a datasource.xml not the one i had defined. Pls help me out. Affecting the performance due to so many hit to db.
    regards,
    Jayashree Jegan

    Hi John,
    Go through this thread of mine. You will get the required information to setup the connection pool.
    SOAP adapter: WSDL issue
    Also just check in Visual Studio Help .NET Connector for Connection Config class settings. You will see all the relevent parameters related with connection pool.
    Regards.

  • Websphere Application Server 5.1 Hangs when using Oracle Connection Pool

    I have a j2ee application that runs on WAS 5.1 ( IBM JDK 1.4 ) and Oracle 10g 10.2.0 . My customer is doing load testing with 25 virtual users and a connection pool with a max size of 10. When the test starts all 25 users attempt to get a connection, and the first 10 get a connection. At this point the application server hangs with the connection pool in allocation. This is seen in Tivoli. Each thread only needs one connection to process it's request.
    I have my own home grown connection pool which when used under this load does not experience and issue. Monitoring from Oracle's admin console I see a max of 10 sessions. The home grows connection pool does not use a WAS DataSource.
    I have configured my application to use DB2 with a WAS DataSource and the application server does not hang. Monitoring using Tivoli shows the connection pool going into allocation, but it recovers as is expected.
    Are there any known issues with the Oracle JDBC drivers when used with WAS 5.1 DataSources?
    Any direction would be helpful, as I currently thing there is an issue with Oracle's Connection Pool and the IBM JVM.
    Thanks,
    J

    just an attention call: OracleDatasource connection pool does not accept parameters such as removeAbandoned, minEvictableIdleTimeMillis, timeBetweenEvictionRunsMillis, etc, these are specific for the tomcat dbcp implementation (http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#JDBC_Data_Sources).
    For the accepted ones read this http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/concache.htm
    Edited by: user7428636 on 24/Jan/2011 6:22

  • Oracle connection pool problem (dbcp binded with  jtom)

    Hi,
    my webserver is Tomcat5.0.18, I want to offer the connection pool and transaction management
    in my currently system
    I know in Tomcat5.0 version, we can use the DBCP to offer the database connection pool
    service, to apply the transaction management in my system, I adapt the JTOM
    now, my problem is
    to use DBCP, I setup the datasource factory to be
    org.apache.commons.dbcp.BasicDataSourceFactory, the connection pool is ok, but
    the transaction management offerred by JTOM will failure
    to make the tranaction management of JTOM succeed, I have to setup the datasource factory to be
    org.objectweb.jndi.DataSourceFactory, but the connection pool offerred by Tomcat will failure now
    it seems that these two datasource factory has conflict
    How can I do?, I don't want to use the connection pool offerred in JTOM
    Anyone can help me??
    Thanks in advance

    Hi,
    I don't know the solution for JOTM, but you could try this JTA and its connection pools:
    http://www.atomikos.com ships a JTA that integrates with Tomcat and also provides JDBC connection pooling. There is a GUI control panel so that you don't have to know the XML details for Tomcat's config files.
    Best,
    Guy

  • Urgent Help Required for Connect Four Game

    Hi all,
    I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the internet which helped me little bit. But there are lot of problems I am facing developing the whole game. I have drawn the Board and the two players can play. The players numbers can fill the board, but I have problem implementing the winner for the game. I need to implement the hasWon() method for Horizontal win, Vertical win and Diagonal win. I also found some code examples on the net but I was unable to make it working. I have 5 classes and one interface which I m implementing. The main problem is how to implement the hasWon() method in the PlayGame class below with Horizontal, vertical and diagonal moves.
    Sorry there is so much code.
    This the interface I must implement, but now I am only implementing the int move() of this interface. I will implement the rest later after solving the winner problem with your help.
    Interface code..............
    interface Player {
    void init (Boolean color);
    String name ();
    int move ();
    void inform (int i);
    Player1 class......................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class Player1 implements Player
    public Player1()
    public int move()
    Scanner scan = new Scanner(System.in);
    // BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
    int player1;
    System.out.println ("What is your Number, player 1?");
    player1 = scan.nextInt();
    System.out.println ("Hey number"+player1+" are you prepared to CONNECT FOUR");
    System.out.println();
    return player1;
    //Player.move();
    //return player1;
    }//end move method
    public void init (Boolean color)
    public void inform (int i)
    public String name()
    return "Koonda";
    }//end player1 class
    Player2 class...........................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class Player2 implements Player
    public int move()
    //int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
    // cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
    //int num1, num2;
    Scanner scan = new Scanner(System.in);
    // BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
    int player2;
    System.out.println ("What is your Number, player 2?");
    player2 = scan.nextInt();
    System.out.println ("Hey "+player2+" are you prepared to CONNECT FOUR");
    System.out.println();
    //return player1;
    return player2;
    }//end move method
    public void init (Boolean color)
    public void inform (int i)
    public String name()
    return "malook";
    }//end player1 class
    PlayGame class which contains all the functionality.........................................................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class PlayGame
    //Player player1;
    //Player player2;
    int [][]ConnectFourArray;
    boolean status;
    int winner;
         int player1;
         int player2;
         public PlayGame()
              //this.player1 = player1;
              //this.player2 = player2;
         public void StartGame()
         try{
         // int X = 0, Y = 0;
         //int value;
         int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
    cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
         int[][] ConnectFourArray = new int[6][7];
         int num1, num2;
         for(int limit=21;limit!=0;limit--)
    BufferedReader selecter = new BufferedReader (new InputStreamReader(System.in));
    String column1;
    System.out.println();
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    System.out.println ("Please Select a column of 0 through 6 ");
    column1 = selecter.readLine();
    num1= Integer.parseInt(column1);
    System.out.println();
    if (num1==0){
    ConnectFourArray[cup0][0]=1;
    cup0=cup0-1;
    else if (num1==1){
    ConnectFourArray[cup1][1]=1;
    cup1=cup1-1;
    else if (num1==2){
    ConnectFourArray[cup2][2]=1;
    cup2=cup2-1;
    else if (num1==3){
    ConnectFourArray[cup3][3]=1;
    cup3=cup3-1;
    else if (num1==4){
    ConnectFourArray[cup4][4]=1;
    cup4=cup4-1;
    else if (num1==5){
    ConnectFourArray[cup5][5]=1;
    cup5=cup5-1;
    else if (num1==6){
    ConnectFourArray[cup6][6]=1;
    cup6=cup6-1;
    System.out.println();
    BufferedReader selecter2 = new BufferedReader (new InputStreamReader(System.in));
    String column2;
    System.out.println();
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    System.out.println ("Please Select a column of 0 through 6 ");
    column1 = selecter.readLine();
    num1= Integer.parseInt(column1);
    System.out.println();
    if (num1==0){
    ConnectFourArray[cup0][0]=2;
    cup0=cup0-1;
    else if (num1==1){
    ConnectFourArray[cup1][1]=2;
    cup1=cup1-1;
    else if (num1==2){
    ConnectFourArray[cup2][2]=2;
    cup2=cup2-1;
    else if (num1==3){
    ConnectFourArray[cup3][3]=2;
    cup3=cup3-1;
    else if (num1==4){
    ConnectFourArray[cup4][4]=2;
    cup4=cup4-1;
    else if (num1==5){
    ConnectFourArray[cup5][5]=2;
    cup5=cup5-1;
    else if (num1==6){
    ConnectFourArray[cup6][6]=2;
    cup6=cup6-1;
    System.out.println();
    System.out.println();
    catch (Exception E){
    System.out.println("Error with input");
    System.out.println("Would you like to play again");
    try{
    String value;
    BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
    // Scanner scan = new Scanner(System.in);
    System.out.println("Enter yes to play or no to quit");
    // value = scan.nextLine();
    // String value2;
    value = reader.readLine();
    //value2 = reader.readLine();
    if (value.equals("yes"))
    System.out.println("Start again");
    StartGame(); // calling the StartGame method to play a game once more
    else if (value.equals("no"))
    System.out.println("No more games to play");
    // System.exit(0);
    else
    System.exit(0);
    System.out.println();
    catch (Exception e){
    System.out.println("Error with input");
    finally
    System.out.println(" playing done");
    //StartGame();
    //check for horizontal win
    public int hasWon()
    int status = 0;
    for (int row=0; row<6; row++)
    for (int col=0; col<4; col++)
    if (ConnectFourArray[col][row] != 0 &&
    ConnectFourArray[col][row] == ConnectFourArray[col+1][row] &&
    ConnectFourArray[col][row] == ConnectFourArray[col+2][row] &&
    ConnectFourArray[col][row] == ConnectFourArray[col+3][row])
    //status = true;//int winner;
    if(status == player1)
    System.out.println("Player 1 is the winner");
    else if(status == player2)
    System.out.println("Player 2 is the winner" );
    }//end inner for loop
    }// end outer for loop
    } // end method Winner
    return status;
    }//end class
    ClassConnectFour which designs the board........................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class ClassConnectFour
         //Player player1;
         //Player player2;
         public ClassConnectFour()
              //this.player1 = player1;
    public void DrawBoard()
    int[][] ConnectFourArray = new int[6][7] ;
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    }//end class
    TestConnetFour class which uses most of the above class..................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class TestConnectFour
    public static void main(String[] args)
    ClassConnectFour cf = new ClassConnectFour();
    cf.DrawBoard();
    Player1 player1 = new Player1();
    Player2 player2 = new Player2();
    player1.move();
    player2.move();
    System.out.println("Number 1 belongs to player " + player1.name());
    System.out.println("Number 2 belongs to player " + player2.name());
    PlayGame pg = new PlayGame();
    pg.StartGame();
    pg.hasWon();
    //pg.Play();
    //System.out.println(player.name());
    //System.out.println(player2.name());
    }// end main
    }//end class
    I am sorry for all this junk code but I only understand it this way. Your urgent help is required. Looking forward to your reply.
    Thanks in advance.
    Koonda
    //

    Hi,
    Thanks for your help but I really don't understand the table lookup algorithm. Could you please send me some code to implement that.
    I will send you the formatted code as well
    Thanks for your help.
    looking forward to your reply.
    Koonda
    Hi all,
    I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the internet which helped me little bit. But there are lot of problems I am facing developing the whole game. I have drawn the Board and the two players can play. The players numbers can fill the board, but I have problem implementing the winner for the game. I need to implement the hasWon() method for Horizontal win, Vertical win and Diagonal win. I also found some code examples on the net but I was unable to make it working. I have 5 classes and one interface which I m implementing. The main problem is how to implement the hasWon() method in the PlayGame class below with Horizontal, vertical and diagonal moves.
    Sorry there is so much code.
    This the interface I must implement, but now I am only implementing the int move() of this interface. I will implement the rest later after solving the winner problem with your help.
    Interface code..............
    interface Player {
    void init (Boolean color);
    String name ();
    int move ();
    void inform (int i);
    Player1 class......................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class Player1 implements Player
    public Player1()
    public int move()
    Scanner scan = new Scanner(System.in);
    // BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
    int player1;
    System.out.println ("What is your Number, player 1?");
    player1 = scan.nextInt();
    System.out.println ("Hey number"+player1+" are you prepared to CONNECT FOUR");
    System.out.println();
    return player1;
    //Player.move();
    //return player1;
    }//end move method
    public void init (Boolean color)
    public void inform (int i)
    public String name()
    return "Koonda";
    }//end player1 class
    Player2 class...........................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class Player2 implements Player
    public int move()
    //int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
    // cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
    //int num1, num2;
    Scanner scan = new Scanner(System.in);
    // BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
    int player2;
    System.out.println ("What is your Number, player 2?");
    player2 = scan.nextInt();
    System.out.println ("Hey "+player2+" are you prepared to CONNECT FOUR");
    System.out.println();
    //return player1;
    return player2;
    }//end move method
    public void init (Boolean color)
    public void inform (int i)
    public String name()
    return "malook";
    }//end player1 class
    PlayGame class which contains all the functionality.........................................................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class PlayGame
    //Player player1;
    //Player player2;
    int [][]ConnectFourArray;
    boolean status;
    int winner;
    int player1;
    int player2;
    public PlayGame()
    //this.player1 = player1;
    //this.player2 = player2;
    public void StartGame()
    try{
    // int X = 0, Y = 0;
    //int value;
    int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
    cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
    int[][] ConnectFourArray = new int[6][7];
    int num1, num2;
    for(int limit=21;limit!=0;limit--)
    BufferedReader selecter = new BufferedReader (new InputStreamReader(System.in));
    String column1;
    System.out.println();
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    System.out.println ("Please Select a column of 0 through 6 ");
    column1 = selecter.readLine();
    num1= Integer.parseInt(column1);
    System.out.println();
    if (num1==0){
    ConnectFourArray[cup0][0]=1;
    cup0=cup0-1;
    else if (num1==1){
    ConnectFourArray[cup1][1]=1;
    cup1=cup1-1;
    else if (num1==2){
    ConnectFourArray[cup2][2]=1;
    cup2=cup2-1;
    else if (num1==3){
    ConnectFourArray[cup3][3]=1;
    cup3=cup3-1;
    else if (num1==4){
    ConnectFourArray[cup4][4]=1;
    cup4=cup4-1;
    else if (num1==5){
    ConnectFourArray[cup5][5]=1;
    cup5=cup5-1;
    else if (num1==6){
    ConnectFourArray[cup6][6]=1;
    cup6=cup6-1;
    System.out.println();
    BufferedReader selecter2 = new BufferedReader (new InputStreamReader(System.in));
    String column2;
    System.out.println();
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    System.out.println ("Please Select a column of 0 through 6 ");
    column1 = selecter.readLine();
    num1= Integer.parseInt(column1);
    System.out.println();
    if (num1==0){
    ConnectFourArray[cup0][0]=2;
    cup0=cup0-1;
    else if (num1==1){
    ConnectFourArray[cup1][1]=2;
    cup1=cup1-1;
    else if (num1==2){
    ConnectFourArray[cup2][2]=2;
    cup2=cup2-1;
    else if (num1==3){
    ConnectFourArray[cup3][3]=2;
    cup3=cup3-1;
    else if (num1==4){
    ConnectFourArray[cup4][4]=2;
    cup4=cup4-1;
    else if (num1==5){
    ConnectFourArray[cup5][5]=2;
    cup5=cup5-1;
    else if (num1==6){
    ConnectFourArray[cup6][6]=2;
    cup6=cup6-1;
    System.out.println();
    System.out.println();
    catch (Exception E){
    System.out.println("Error with input");
    System.out.println("Would you like to play again");
    try{
    String value;
    BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
    // Scanner scan = new Scanner(System.in);
    System.out.println("Enter yes to play or no to quit");
    // value = scan.nextLine();
    // String value2;
    value = reader.readLine();
    //value2 = reader.readLine();
    if (value.equals("yes"))
    System.out.println("Start again");
    StartGame(); // calling the StartGame method to play a game once more
    else if (value.equals("no"))
    System.out.println("No more games to play");
    // System.exit(0);
    else
    System.exit(0);
    System.out.println();
    catch (Exception e){
    System.out.println("Error with input");
    finally
    System.out.println(" playing done");
    //StartGame();
    //check for horizontal win
    public int hasWon()
    int status = 0;
    for (int row=0; row<6; row++)
    for (int col=0; col<4; col++)
    if (ConnectFourArray[col][row] != 0 &&
    ConnectFourArray[col][row] == ConnectFourArray[col+1][row] &&
    ConnectFourArray[col][row] == ConnectFourArray[col+2][row] &&
    ConnectFourArray[col][row] == ConnectFourArray[col+3][row])
    //status = true;//int winner;
    if(status == player1)
    System.out.println("Player 1 is the winner");
    else if(status == player2)
    System.out.println("Player 2 is the winner" );
    }//end inner for loop
    }// end outer for loop
    } // end method Winner
    return status;
    }//end class
    ClassConnectFour which designs the board........................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class ClassConnectFour
    //Player player1;
    //Player player2;
    public ClassConnectFour()
    //this.player1 = player1;
    public void DrawBoard()
    int[][] ConnectFourArray = new int[6][7] ;
    for ( int row=0; row < ConnectFourArray.length; row++ ){
    System.out.print("Row " + row + ": ");
    for ( int col=0; col < ConnectFourArray[row].length; col++ )
    System.out.print( ConnectFourArray[row][col] + " ");
    System.out.println();
    System.out.println();
    }//end class
    TestConnetFour class which uses most of the above class..................
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    public class TestConnectFour
    public static void main(String[] args)
    ClassConnectFour cf = new ClassConnectFour();
    cf.DrawBoard();
    Player1 player1 = new Player1();
    Player2 player2 = new Player2();
    player1.move();
    player2.move();
    System.out.println("Number 1 belongs to player " + player1.name());
    System.out.println("Number 2 belongs to player " + player2.name());
    PlayGame pg = new PlayGame();
    pg.StartGame();
    pg.hasWon();
    //pg.Play();
    //System.out.println(player.name());
    //System.out.println(player2.name());
    }// end main
    }//end classI am sorry for all this junk code but I only understand it this way. Your urgent help is required. Looking forward to your reply.
    Thanks in advance.
    Koonda

  • Hi Guys, can you please help me with Connection Pooling.

    I have:-
    Tomcat 5.0.27
    MySQL 4
    Apache 2.0.
    JSP web pages.
    I have been trying to get connection pooling working but i havent been successful yet. Please do help me make it happen.
    I have posted my server.xml and web.xml from /conf/. They are not edited. I have also included the pages that I am currently ussing to connect to the database.
    I need you to assist me with how I should edit the above.
    1.     SERVER.XML
    Where and how should I edit this file?
    2.     WEB.XML
    Where and how should I edit this file?
    3.     DATABASE_INFO.JSP
    <%
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    %>
    <%!
    public java.sql.Connection dataconnect() throws SQLException {
    Connection database_connector;
    database_connector = DriverManager.getConnection("jdbc:mysql://localhost/publications?user=hello&password=hello");
    return database_connector;
    %>
    <%!
    public java.sql.Connection adminconnect(javax.servlet.http.HttpSession session) throws SQLException {
    Connection database_connector;
    if (session.getAttribute("s_conn")!=null) {
    database_connector = (Connection) session.getAttribute("s_conn");
    if (database_connector.isClosed()) {
    database_connector = DriverManager.getConnection("jdbc:mysql://localhost/publications?user=hello&password=hello");
    } else {
    database_connector = DriverManager.getConnection("jdbc:mysql://localhost/publications?user=hello&password=hello");
    session.setAttribute("s_conn", database_connector);
    return database_connector;
    %>
    <%!
    public String filedir() {
    String directory = "C:/Tomcat/webapps/ROOT/publications/";
    return directory;
    %>
    etc
    Database Name : publications

    Hi,
    1- put your jdbc driver jar file in $CATALINA_HOME/common/lib (ex: C:\tomcat\common\lib )
    2- Next, modify the web application deployment descriptor (/WEB-INF/web.xml) to declare the JNDI name under which you will look up preconfigured data source
    take care of the ordering as below so resourc-ref tag is after taglib
    <resource-ref>
    <description>
    Resource reference to a factory for java.sql.Connection
    instances that may be used for talking to a particular
    database that is configured in the server.xml file.
    </description>
    <res-ref-name>
    jdbc/EmployeeDB
    </res-ref-name>
    <res-type>
    javax.sql.DataSource
    </res-type>
    <res-auth>
    Container
    </res-auth>
    </resource-ref>
    3- add an element like this to the /META-INF/context.xml file in the web application. ( under ../webapps/mywebapplication/WEB-INF
    <Context ...>
    <Resource name="jdbc/EmployeeDB" auth="Container"
    type="javax.sql.DataSource" username="hello" password="hello"
    driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/publications"
    maxActive="8" maxIdle="4"/>
    </Context>
    4- code sample
    Context initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
    DataSource ds = (DataSource)
    envCtx.lookup("jdbc/EmployeeDB");
    Connection conn = ds.getConnection();
    ... use this connection to access the database ...
    conn.close();
    The default data source support in Tomcat is based on the DBCP connection pool from the jakarta commons
    Regards,
    Alan Mehio
    London,UK

  • Urgent please - Error Testing connection pool

    I have a connection pool and datasource working fine, but when I click at the testing hyperlink on the weblogic console/jdbc/testing, the following message apear at the Unix console.
    Caused by: javax.management.MalformedObjectNameException: bad object name,property Location has multiple values in Name=hom59DataSource,Type=ApplicationRuntime,Location=cbdHom,ServerRuntime=cbdHom,Loc
    ation=cbdHom,Type=JDBCDataSourceRuntime
    at java.lang.Throwable.<init>(Throwable.java:57)
    at java.lang.Throwable.<init>(Throwable.java:68)
    at weblogic.management.WebLogicObjectName.extractProperties(WebLogicObjectName.java:571)
    at weblogic.management.WebLogicObjectName.<init>(WebLogicObjectName.java:326)
    at weblogic.management.WebLogicObjectName.setParentFromObjectName(WebLogicObjectName.java:934)
    at weblogic.management.WebLogicObjectName.populate(WebLogicObjectName.java:851)
    at weblogic.management.WebLogicObjectName.<init>(WebLogicObjectName.java:328)
    at weblogic.management.WebLogicObjectName.<init>(WebLogicObjectName.java:822)
    at weblogic.management.jmx.MBeanServerInvocationHandler.getWebLogicObjectName(MBeanServerInvocationHandler.java:80)
    Somebody please could help me?
    Message was edited by:
    Denimar

    Have figured this out. Need to set the "Test Connections" settings under Configurations
    (Advanced Options) for the Connection Pool.
    Thanks for your help :)
    Joe Weinstein <[email protected]> wrote:
    Everbright wrote:
    Hi,
    I've just started working on the Avitek Tutorials.
    Encountered the following error message when testing the connectionpools for
    both the XA and non-XA connections.
    Warning! Connectivity to backend database not verified. This is eitherbecause
    required connection pool attributes "TestConnectionsOnReserve" or "TestConnectionsOnRelease"
    have not been enabled, or an invalid value has been specified for attribute"TestTableName".
    Please check the server log for more details..
    Any ideas what might be wrong?It is likely that some part of the information you specified about how
    to connect to
    your database was incorrect, so weblogic was unable to make a pool of
    connections.
    We will know more if you show us the server log file, which will contain
    messages
    about any errors it suffered during startup...
    Joe
    Thanks!

  • Help! JDBC connection pooling lookup in Web server

    Hi,
    I have a probelm looking up a JDBC Resource
    whenever I try to do that I got the message saying:
    "sourceWEB3885: Name jdbc is not bound in this Context "
    I have created a connection pool and JDBC Resource
    <JDBCCONNECTIONPOOL name="mypool" datasourceclassname="oracle.jdbc.pool.OracleDataSource" steadypoolsize="8" maxpoolsize="32" poolresizequantity="2" idletimeout="300" maxwaittime="60000" connectionvalidationrequired="on" connectionvalidationmethod="auto-commit" validationtablename="test_table" failallconnections="off" isolationlevelguaranteed="on" transactionisolationlevel="read-uncommitted">
    <PROPERTY name="user" value="user"/>
    <PROPERTY name="URL" value="jdbc:oracle:thin:@10.10.10.10:1521:mydb"/>
    <PROPERTY name="password" value="password"/>
    </JDBCCONNECTIONPOOL>
    <JDBCRESOURCE jndiname="jdbc/mypoolds" poolname="mypool" enabled="true"/>
    I tried to lookup the data Resources like this:
    ic.lookup("java:comp/env/jdbc/paspoolds");
    I also tried other varaitions like
    ic.lookup("paspoolds");
    but without any luck.
    I'm not sure if the JDBC Resource didn't created properly or I didn't do the lookup properly.
    please advice.
    thanks.
    Ahmed

    I'm also getting the:
    [11/Nov/2004:16:35:30] warning ( 9818): WEB7103: Exception while binding global resources: javax.naming.NameNotFoundException: WEB3885: Name java:comp is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:811)
    Running Sun Java System Web Server 6.1...
    In sun-web.xml (I put 2 entries - just in case):
    <resource-ref>
    <res-ref-name>epdmDS</res-ref-name>
    <jndi-name>java:comp/env/jdbc/epdmDS</jndi-name>
    </resource-ref>
    <resource-ref>
    <res-ref-name>jdbc/epdmDS</res-ref-name>
    <jndi-name>java:comp/env/jdbc/epdmDS</jndi-name>
    </resource-ref>
    Web.xml:
    <resource-ref>
    <description> JNDI DataSource </description>
    <res-ref-name>epdmDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <!-- <res-sharing-scope>Sharable</res-sharing-scope> -->
    </resource-ref>
    Java code:
    import javax.sql.DataSource;
    import javax.naming.InitialContext;
    private final static String jdbcPath = "java:comp/env/jdbc/epdmDS";
    createDS: {
    InitialContext ctx;
    // Instantiate data source objects and store in app context
    try {
    ctx = new InitialContext();
    DataSource epdmDS = (DataSource)ctx.lookup( jdbcPath );
    sc.setAttribute( "epdmDS", epdmDS );
    } catch( Exception e ) {
    logErr("EPDMServlet: Cannot create data source for EPDM jdbc path: "+jdbcPath );
    break createDS;
    server.xml: (I put in 2 just in case...trying to get it to work...)
    <JDBCCONNECTIONPOOL name="epdmDS" datasourceclassname="oracle.jdbc.pool.OracleDataSource" steadypoolsize="8" maxpoolsize="32" poolresizequantity="2" idl
    etimeout="300" maxwaittime="60000" connectionvalidationrequired="on" connectionvalidationmethod="auto-commit" validationtablename="" failallconnections="off"
    transactionisolationlevel="read-uncommitted" isolationlevelguaranteed="off">
    <PROPERTY name="User" value="xxx"/>
    <PROPERTY name="URL" value="jdbc:oracle:thin:@xxxxx:1525:xxxxx"/>
    <PROPERTY name="Password" value="xxx"/>
    </JDBCCONNECTIONPOOL>
    <JDBCRESOURCE jndiname="jdbc/epdmDS" poolname="epdmDS" enabled="on"/>
    <JDBCCONNECTIONPOOL name="epdmDS" datasourceclassname="oracle.jdbc.pool.OracleDataSource" steadypoolsize="8" maxpoolsize="32" poolresizequantity="2" idl
    etimeout="300" maxwaittime="60000" connectionvalidationrequired="on" connectionvalidationmethod="auto-commit" validationtablename="" failallconnections="off"
    transactionisolationlevel="read-uncommitted" isolationlevelguaranteed="off">
    <PROPERTY name="User" value="xxx"/>
    <PROPERTY name="URL" value="jdbc:oracle:thin:@xxxxx:1525:xxxxx"/>
    <PROPERTY name="Password" value="xxx"/>
    </JDBCCONNECTIONPOOL>
    <JDBCRESOURCE jndiname="jdbc/epdmDS" poolname="epdmDS" enabled="on"/>
    <JDBCRESOURCE jndiname="epdmDS" poolname="epdmDS" enabled="on"/>

  • Urgent help : Nomadic computing / connected env(long)

    Hi,
    I need some urgent help on the following problem.
    Platform : NT 3.51 as the Env Mgr, server and clients.
    Forte : 2.0.E.1
    The test case is simple :
    Multiple, lets say 3, Forte environments (each a NT machine, but that
    shouldn't be significant), of which one is the "home" environment, Env0,
    as well as the other remote environments, Env1 and Env2. I need to
    connect to Env1, Env2 from Env0 on a completely dynamic basis, i.e. I
    have a list of NS addresses (IP & port) and the particular one is
    selected by the user. "Connect" means anything from the very basic
    invoke a method on a service, to the more sophisticated inspect (&
    change) instruments and invoke commands on all system agents and custom
    agents.
    I started off with the new nomadic stuff : As per Forum and technote
    (#?) x 3. I installed my server partition on Env1 and Env2 and started
    the client with the -fnoins flag. Then I dynamically set the environment
    variable (in NT its in HKEY_CURRENT_USER in the NT registry)
    FORTE_NS_ADDRESS to the new environment, Env1. When I invoked the method
    it fired off the part in the right Env. Then I changed the
    FORTE_NS_ADDRESS, to Env2, and did the task.part.DistObjLOcationMgr.Rele
    aseConnection(EnvMgr).. thing. This was fine. The question now was : How
    do I "connect" to the newly set Env ? I tried everything from simply
    calling my server partition, to server...task.part.GetEnvMgr, to
    registering anchored objects on the blessed ObjLocationMgr ! It just
    didnt connect to the new Env : It stayed connected to Env1 !
    Then I got onto connected environments. Here I also tried a couple of
    things: Most significantly, connecting to Env1 and setting the
    environment search path also did the trick, but again disconnecting from
    Env1 seem troublesome : Q : How do I seperate the original Env0 and Env1
    ? Forte seem to think that its all one big environment now and gave
    strange errors when I disconnected from Env1, connected to Env2 and
    tried to set the environment search path to Env2. Another Q, is there a
    way to dynamically set the environment search path for a SO ? All I
    could do was set the NS environment search path.
    Anyway, my apologies for this long dragged out e-mail, but any ideas
    will help...I'm getting desperate !
    Anton van Niekerk

    Well I hate to say it but I think you borked it somehow. I have no idea what you mean by that green chip connected with two wires and that blue long chip but the fact that you are referring to internal parts that way tells me you didn't really know what you were doing in there. There is a Manual and it can be followed step by step rather than just rushing in and turning screws. I suggest putting it all in a basket and taking it to a repair shop where they can figure it out if possible. Trust me, you will not be the first such case they have ever seen.

  • Need urgent help on Oracle project

    Hi people, I am working on a project using oracle sql, been struggling quite a bit. Have been issued an ultimatum to improve performance.
    Wondering if anyone here can be of any help.
    writing oracle reports solely on sql plus, based on finctional specs business rules.
    wondering if anyone could assist with some difficult areas and offer assistance if and when needed.

    Without seeing any of your extra info, to delete from the table, you would want to add something like this trigger in the After Parameter Trigger:
    BEGIN
    IF :old_or_new = 'O'
       then
       delete from clothes
       where size = :P_COLOR;
    end if;
    END;You also may want to try posting in this forum for more specific Reports questions:
    Reports

  • I need help with socket connection pooling please

    I need a basic connection pooling system for the code below users sets number connections 5 etc.
    <main class>
    s = new ListService(ssock.accept(),serverDir); //give list to client
    Thread t = new Thread(s);
    t.start();
    <main class>
    class ListService implements Runnable
    Socket client;
    String serverDir;
    public ListService(Socket client,String serverDir)
    this.client = client;
    this.serverDir = serverDir;
    public void run()
    try
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
    // send something to client
    catch(Exception e)
    System.out.println(e);
    System.out.println("client disconnected\n");
    catch(Exception e){}
    Thank you so much

    My code already accepts multi clients I need pooling only 5 clients can be using the server at a time when one client disconnects that means another incoming client can enter the pool to use the server.
    I tried to do a counter so when a connection is made it increments and then if counter>=numOfClients
    set a variable to true or false and this is sent with the server setup so it determines if the server code is run or it just closes the connection but there is no way I can access the counter variable from within a runnable class thread when a client closes connection it should -1 from the variable
    thanks

  • Help needed for Connection Pooling

    I want to know about connection pooling in java.Can anyone suggest a best tutorial or link to learn this.

    http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html
    http://java.sun.com/products/jndi/tutorial/ldap/connect/pool.html
    or better Google it.

  • Help with Oracle connection

    Hi,
    I am new to the whole Java experience and am wading my way through servlets pretty well. However, I have run across a problem that I simply cannot connect the pieces of. I have a set of servlets that I am planning on deploying to a client. These servlets will connect to an Oracle database. Since the client connection url/user/password will not be the same as the values I am using in my development efforts, I don't want to set the values in my servlets, i.e:
    OracleConnectionPoolDataSource ocpds = new OracleConnectionPoolDataSource();
    ocpds.setURL("jdbc:oracle:thin:@databasename");
    ocpds.setUser("User");
    ocpds.setPassword("Password");
    // Create a pooled connection
    PooledConnection pc = ocpds.getPooledConnection();
    I have created my servlets using Oracle's JDeveloper, so I have a connections.xml file and a data-sources.xml file which contain the URL, userID and Password of the instance to connect to.
    Is there a way I can grab that information from the connections.xml file or the data-sources.xml file from within my servlet, so I don't have to give static values for the URL, userID and password within the servlet?
    Thanks for the help,
    -Pete

    Hi Pete,
    You can do either one of two solutions:
    (1) Your XML files idea is a good one. Read them in the servlet init method and hang onto the values.
    (2) You can create a JNDI DSN and use a pooled connection that's maintained by your servlet/JSP container. Here's how I do it with Tomcat 4.1:
    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
    Maybe that will give you some ideas on how to accomplish the same thing using your container. - MOD

Maybe you are looking for

  • Family member upgrade question answered by a cust svc rep

    Ok, here is my situation, which I am sure applies to a lot of people here on the forums.  My wife is eligible for an upgrade on her line (has been eligible for upgrade since 2008), I am eligible for an upgrade on my line only by calling and ordering

  • How to get Parameters in a jsp page called by VB program via xmlHttp

    I have a VB programm sending a request using xmlHttp. xmlHttp.Open "POST", varTarget, True 'True means asynchronous xmlHttp.Send xmlSendStr This worked fine with ASP the crucial ASP code was:      set xml = server.createObject("MSXML2.DOMDocument")  

  • How to send a document from pages in email

    Can u send a document from pages in email that can be opened by a PC.

  • Reg File- Webservice Async-Sync bridge

    Hi, I have File -WS async-Sync scenario. I have configured the RequestResponseBean-CallSAP-ResponseOnewayBean in my sender CC When i execute the scenario, the sender channel is throwing Error: java.lang.NullPointerException When i check the sender ch

  • "Open With" File Association

    How do I associate specific file types with a specifc application (i.e. all .mp3 files to "open with" Quicktime)? I tried opening a file and selecting the "Always Open With" box, but this only affects that one file, not every file of it's type. Thank