JDBC settings in XI

Hi Experts,
We have both sender and receiver scenarios and are running in production system related to JDBC Adapter, now there is a plan of changing the Oracle configuration at DB side like host name connection settings not in XI.
Once if the changes are done at DB side, i can change the settings in XI CC parameters, this is i know.
Is there any configuration settings i need to change at adminstration part apart from CC changes or is there any drivers needs to instal again into XI system.
Can some body explain what are the settings needs to be done in XI system.
Thanks in Advance
Neeru

Hi Neeru,
I hope the database you are changing is not XI database. If yes then you dont need to install drivers since you are only changing the parameters in database. Only thing you need to change is the CC parameters.
Regards,
---Satish

Similar Messages

  • MS SQL Server 2000 JDBC Settings

    Hi,
    I am new to weblogic and i am developing my final year project using weblogic 8.1 SP 3.0. I want to use MS SQL Sever as a database. Can anyone tell me how to configure MS SQL Server for weblogic and how to communicate with it with the help of an example. I have tried my best to configure it by searching material but it is not working. Please help. You can also send me the reply on my email id i.e [email protected]
    Regards,
    SameeR.

    Deepak Vohra wrote:
    Thanks for trying to help, but this below is unnecessary and counter-productive.
    WebLogic comes already with a comprehensively superior JDBC driver for MS SQLServer
    (2000 and up). Just follow the documentation at:
    http://e-docs.bea.com/wls/docs81/jdbc_drivers/mssqlserver.html#1043185
    Joe
    To configure WebLogic with SQL Server:
    1. Install the SQL Server with SQL2kdesksp3.exe
    2. Add the SQL Server driver jar files msbase.jar, msutil.jar and mssqlserver.jar to the Classpath in the startWebLogic script.
    3. In the administration console configure a new JDBC connnection. In the Configure a JDBC Connection Pool frame select MS SQL Server in the Database Type field. Select Microsoft???s MS SQL Server Driver (Type 4 ) driver as the Database Driver.
    4. In the Connection Properties frame specify the Host Name as localhost, Port as 1433, Database User Name as sa and Password as the password used login to the database.
    5. In the Test database connection frame specify the Driver Classname as com.microsoft.jdbc.sqlserver.SQLServerDriver, URL as jdbc:microsoft:sqlserver://localhost:1433
    6. In the Create and deploy frame select the server to which the JDBC Connection pool is to be deployed.

  • Get/update jdbc settings by using wlst

    Hi all!
    Today I have task to get current jdbc setting and save it to file, but something is wrong in my code:
    cd('/JDBCSystemResources')
    file=open(filename, "w")+
    +jdbclist=cmo.getJDBCSystemResources()+
    +for ijdbc in jdbclist:+
    +dName=ijdbc.getName();+
    +cd('/JDBCSystemResources/'+dName+'/JDBCResource/'+dName+'/JDBCDriverParams/'+dName+'/Properties/'+dName+'/Properties/user')+
    +userlogin=cmo.getValue()+
    +print dName, userlogin+
    +s=dName+' '+userlogin+'\n'+
    +file.write(s)+
    Problem invoking WLST - Traceback (innermost last):
    (no code object) at line 0
    File "C:\wlst\tmp\demo.py", line 27
    dName=ijdbc.getName();
    ^
    SyntaxError: invalid syntax
    It worked if run from wl console, but failed by running from script.
    What is wrong?
    Thank you!

    I just went through the similar thing. Here is what I did:
    cd('/')
    dsList=cmo.getJDBCSystemResources()
    for i in dsList: 
      dsName=i.getName(); 
      cd('/JDBCSystemResources/'+dsName+'/JdbcResource/'+dsName+'/JDBCDriverParams/NO_NAME_0/Properties/NO_NAME_0/Property/user')  

  • Upto how many characters will accept in SELECT query  SENDER JDBC (PI 7.1)

    Hi Friends,
    I have to use Sender JDBC adapter in SAP PI 7.1, I need to use SELECT query only.
    I have a SELECT query is around 2 pages. Is this will accepet in SENDER JDBC in PI 7.1
    Thanks in advance.

    Hi Challarapu,
    You can check it out and if it is not accepted by the same then you need to check the maximal length @ DB settings or JDBC Settings whether it is limited. If not then you are allowed.
    Hope this helps.
    Regards
    Pothana

  • Weblogic.jdbc.extensions.PoolLimitSQLException:No resources avail.  in pool

    Hi,
    We are getting the following exceptions. I am also appending the JDBC settings we are using. This is a high volume transaction application.
    weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool <DataSourceName> to allocate to applications, please increase the size of the pool and retry..
    ERROR;- Error creating a transaction for database default
    org.hibernate.exception.GenericJDBCException: Cannot open connection
    ERROR;- Session not found in endSession for database default. This is not okay. refCount=0
    FATAL;- Found lingering open database session. referenceCount=-1
    <?xml version='1.0' encoding='UTF-8'?>
    <jdbc-data-source xmlns="http://www.bea.com/ns/weblogic/90" xmlns:sec="http://www.bea.com/ns/weblogic/90/security" xmlns:xsi=
    "http://www.w3.org/2001/XMLSchema-instance" xmlns:wls="http://www.bea.com/ns/weblogic/90/security/wls" xsi:schemaLocation="ht
    tp://www.bea.com/ns/weblogic/910/domain.xsd">
    <name>DataSource</name>
    <jdbc-driver-params>
    <url>jdbc:oracle:thin:@serverName:1521:braz2prd</url>
    <driver-name>oracle.jdbc.OracleDriver</driver-name>
    <properties>
    <property>
    <name>user</name>
    <value>brsadmin</value>
    </property>
    </properties>
    <password-encrypted>{3DES}RWHcVDJQGsEUeR3LGNjB9A==</password-encrypted>
    </jdbc-driver-params>
    <jdbc-connection-pool-params>
    <initial-capacity>10</initial-capacity>
    <max-capacity>30</max-capacity>
    <capacity-increment>10</capacity-increment>
    <test-connections-on-reserve>true</test-connections-on-reserve>
    <test-table-name>SQL SELECT 1 FROM DUAL</test-table-name>
    </jdbc-connection-pool-params>
    <jdbc-data-source-params>
    <jndi-name>bharosaDataSource</jndi-name>
    <global-transactions-protocol>OnePhaseCommit</global-transactions-protocol>
    </jdbc-data-source-params>
    </jdbc-data-source>
    Thanks in advance. Please suggest..
    Thanks,
    Shashi.

    Shashi Yarlagadaa wrote:
    Hi,
    We are getting the following exceptions. I am also appending the JDBC settings we are using. This is a high volume transaction application.
    weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool <DataSourceName> to allocate to applications, please increase the size of the pool and retry..
    ERROR;- Error creating a transaction for database default
    org.hibernate.exception.GenericJDBCException: Cannot open connection
    ERROR;- Session not found in endSession for database default. This is not okay. refCount=0
    FATAL;- Found lingering open database session. referenceCount=-1
    <?xml version='1.0' encoding='UTF-8'?>
    <jdbc-data-source xmlns="http://www.bea.com/ns/weblogic/90" xmlns:sec="http://www.bea.com/ns/weblogic/90/security" xmlns:xsi=
    "http://www.w3.org/2001/XMLSchema-instance" xmlns:wls="http://www.bea.com/ns/weblogic/90/security/wls" xsi:schemaLocation="ht
    tp://www.bea.com/ns/weblogic/910/domain.xsd">
    <name>DataSource</name>
    <jdbc-driver-params>
    <url>jdbc:oracle:thin:@serverName:1521:braz2prd</url>
    <driver-name>oracle.jdbc.OracleDriver</driver-name>
    <properties>
    <property>
    <name>user</name>
    <value>brsadmin</value>
    </property>
    </properties>
    <password-encrypted>{3DES}RWHcVDJQGsEUeR3LGNjB9A==</password-encrypted>
    </jdbc-driver-params>
    <jdbc-connection-pool-params>
    <initial-capacity>10</initial-capacity>
    <max-capacity>30</max-capacity>
    <capacity-increment>10</capacity-increment>
    <test-connections-on-reserve>true</test-connections-on-reserve>
    <test-table-name>SQL SELECT 1 FROM DUAL</test-table-name>
    </jdbc-connection-pool-params>
    <jdbc-data-source-params>
    <jndi-name>bharosaDataSource</jndi-name>
    <global-transactions-protocol>OnePhaseCommit</global-transactions-protocol>
    </jdbc-data-source-params>
    </jdbc-data-source>
    Thanks in advance. Please suggest..
    Thanks,
    Shashi.Hi. I suggest turning on the pool's idle connection timeout to
    something slightly longer than you'd expect your longest invocation
    to take, and see if the problem goes away. Also, it is better to
    make your init capacity = 30 rather than ask the pool to grow
    at runtime. Also, keep the capacityIncrement = 1.
    Joe

  • NW04s JDBC Connection for MSSQL not working

    In portal JDBC settings are:
    Connection properties
    URL = jdbc:microsoft:sqlserver://192.168.0.101:1433;DatabaseName=Northwind
    Driver = com.microsoft.jdbc.sqlserver.SqlServerDriver
    User Management
    User mapping type = admin,user
    I assigned a user to Administrator under User Administration
    Visual Administrator settings are:
    DriverName = com.microsoft.jdbc.sqlserver.SqlServerDriver
    URL = jdbc:microsoft:sqlserver://192.168.0.101:1433;DatabaseName=Northwind
    UserName = empty
    Password = empty
    Result
    Connection test fails in portal. The settings appear ok.
    The only thing I can think of is that user specified in portal user mapping is not setup properly on SQLServer.
    Also:
    When I run link:
    http://localhost:53000/TestJDBC_Web/TestJDBCPage.jsp
    my jdbc service MSSQL_JDBC does not appear. MSSQL_JDBC was cloned from SDK_JDBC and the libray for drivers was added
    I am running MSSQL 2000 SP4 but using JDBC drivers for SP3 as I didn't find any for SP4 and assumed they would work for SP4
    What am I missing?

    Raynald,
    I think I am having a similar problem.
    I also cloned the connection names in Vis. Administrator to the SDK_name.
    Indeed it now appears in the test servlet, and I can succesfully execute SQL statements from there.
    So the connector seems ok.
    But I have still problems with the Connection Test in the Portal.
    I am trying to make BI JDBC system to be able to use my database from the Visual Composer.
    I am using these properties:
    CodeLink = com.sap.portal.systems.bi.SAP_BI_JDBC
    ConnectionFactoryClass = SDK_TESTDB
    ConnectionUrl = jdbc:jtds:sqlserver://sapserver:1433;databaseName=TestDb
    (this url is the same as in Vis. Administrator)
    Driver Class Name =  net.sourceforge.jtds.jdbc.Driver
    Fixed Catalog = empty
    Fixed Schema = empty
    System Type = SAP_BI_JDBC
    User Mapping = admin, user
    I am logged in as Administrator, so I added the login credentials at the User Mapping page of the Administrator user.
    When I use Connection Test function from the portal I get the following messages:
    Retrieval of default alias successful
    Connection failed. Make sure user mapping is set correctly and all connection properties are correct.
    What can I do to solve this problem?

  • JDBC 4.0 Driver JDeveloper

    Oracle database 11g JDBC drivers support JDBC 4.0.
    But, JDeveloper does not support the JDBC 4.0 driver.
    Because JDeveloper is pre-configured with a built-in Oracle JDBC driver and if the ojdbc6.jar is used to connect to Oracle database an error gets generated.

    Thanks Steve.
    The error gets generated if the Databases navigator is used to connect to Oracle database with JDBC 4.0 driver.
    1. Set JDK to JDK 6.0 with Tools>Project Properties>Libraries and Classpath>Java SE Version
    2. In the Databases navigator right-click on IDE Connections and select New Connection.
    3. Select Connection Type as "Generic JDBC".
    4. In the Generic JDBC Settings select New in the Driver Class field.
    Specify Driver Class as oracle.jdbc.OracleDriver. Create a library for the ojdbc6.jar and select the library in the Library selection.
    5. Error gets generated:
    The Oracle JDBC driver is built in and cannot be redefined.

  • WLST and JDBC Descriptor files

    I'm trying to change the configuration of an portal domain. In 8.1 this was no problem, but in 9.X there's a notion of a JDBC Descriptor file to describe the JDBC connection.
    So when I run:
    readTemplate(r'/%bea_home%/weblogic92/common/templates/applications/wlp.jar')
    cd('JDBCSystemResource/portalDataSourceAlwaysXA')
    When I look at this JDBC resource all it contains is a reference to a descriptor file.
    How to I change these settings (we're using Oracle and not Pointbase)?
    Second question:
    Where are all the other jdbc settings set? When I run the configuration wizard, I see a lot of data sources - among them a sample data source. These are no in the referenced JDBC descriptor files - so where do they come from? I'm talking about the following data sources which show up in the configuration wizard:
    - p13nDataSource
    - cgDataSource
    - cgDataSource-nonXA
    - samplesDataSource
    As a sidenote - I think that BEA should document how one alters JDBC connections which are already defined inside a template. I haven't found any such documentation.
    Trond Andersen, Invenia AS, http://www.invenia.no

    The problem with the IOException (Permission denied) is
    solved. It arised when I tried to create the domain in my
    ClearCase view. When doing the same thing in my home folder
    I didn't have this problem.
    How about creating a JMSDestinationKey? Anyone having a
    solution for this?
    //M
    "Martin Gustavsson" <[email protected]> wrote:
    >
    >
    >
    Thanks for your quick response. I attach my config.xml.
    //Martin
    Satya Ghattu <[email protected]> wrote:
    Hello Martin,
    Martin Gustavsson wrote:
    Some problems with configToScript (WLST).
    I have a config.xml which I run configToScript on.
    It works fine and the message I get at the end is that I
    should replace "ChangeME" to proper values. For my
    JDBC Connection-pool, I replace it with a cleartext password.
    But what should I replace it with for EmbeddedLDAP and
    SecurityConfiguration? If I run the script
    without changing it I get this critical error:
    <Jun 22, 2004 5:06:01 PM CEST> <Critical> <EmbeddedLDAP>
    <BEA-171517><An error occurred while attempting to get
    exclusive access to the embedded LDAP data files
    directory - temp/myserver/ldap/ldapfiles. The exception thown
    is java.io.IOException: Permission denied.>I haven't seen this myself and could not reproduce. It might
    help if you remove the myResource.setCredential("changeME")
    for the embedded ldap and security configuration from the
    script. Server will assign a default value and you should be
    all set.
    Another problem I have when running the generated script is
    that it fails to create a JMSDestinationKey:
    Error occured while performing create : Cannot create MBean
    of type JMSDestinationKey. You can only create MBean's
    children to the current cmo of type: Domain. Use dumpStack()
    to view the error stack trace.Could you please attach your config.xml?
    Thanks,
    -satya
    Even in interactive mode I have the same problem and the
    dumpStack() gives me zero.
    I'm running on Linux RedHat using WebLogic 8.1SP2.
    Regards,
    Martin

  • Problem using Oracle JDBC Driver

    Hi,
    I try to configure the Oracle JDBC Driver the following way:
    I load the Oracle drivers ojdbc14_g.jar and nls_charset12.jar
    I configure the DataSource using the Driver Class oracle.jdbc.driver.OracleDriver, the database URL: jdbc:oracle:thin:@h50a430:1521:WLP1E1A0 and the User with Password.
    As soon as its activated I get the following error:
    java.rmi.RemoteException: Error occurred while starting application in whole cluster and wait.; nested exception is:
         com.sap.engine.services.deploy.exceptions.ServerDeploymentException: Complex error : server ID 4123350:Cannot start DataSource "Oracle".
         at com.sap.engine.services.deploy.server.DeployCommunicatorImpl.startApplicationAndWait(DeployCommunicatorImpl.java:678)
         at com.sap.engine.services.deploy.server.DeployCommunicatorImpl.startApplicationAndWait(DeployCommunicatorImpl.java:660)
         at com.sap.engine.services.dbpool.deploy.DataSourceManagerImpl.startApplication(DataSourceManagerImpl.java:535)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
    any hint?

    I can't create an Oracle datasource too.
    Uploaded ojdbc14.jar, used the same Oracle jdbc settings as in my jdbc explorer where everything works fine, set initial connections to 1, set SQL Engine to Native SQL,...
    -> won't start.
    I restarted the cluster too. The Datasource is still marked with a red cross in the admin tool.
    This is with the type 1.x setting, as XA seems to be still broken in WAS 6.40.

  • Encrypting Database settings

    Hello everyone,
    In a custome jsp/servlet led web-application, we either store the jdbc settings like database source, database name, username and password in a xml file or we specify them in the servlet itself.
    I want to know that what I should do or rather can do, to keep it (xml file) secret from everyone else so that no one other than me can know the db settings. Like, can we encrypt them or something like that, so that it is not visible even to other developers .. ??
    thanks

    You could create a library in the form of a JAR that you pass off to the other developers and let them just use it. But, really they could extract the JAR and decompile the classes to see the information. I would say give them a temporary username and password to the db and only allow them to see the data they need to see.
    Normally though, developers have access to the database. If they are to read and write to it you can't really hide data from them - minus using the JAR theory. And that's only if they don't care about seeing it. If they really want to get it, they can.
    Sensitive data should be stored in the production database while developers develop against a development database that has no sensitive data in it. That should solve any problems you have.

  • Converting from JDBC to JDNI connection

    I am currently using CR XI (sp3)  JRC in my application to display reports via web pages. I am using Oracle with a JDBC connection. I need to change my JDBC connection to a JNDI connection.  Here are my current connection settings;
    connection_url=jdbc:oracle:thin:@ros-db03:1521:spndgwin
    connectionString=!jdbc:oracle:thin:@ros-db03:1521:spndgwin!jdbc:oracle:thin:/@ros-db03:$:spndgwin
    database_classname=oracle.jdbc.driver.OracleDriver
    Can someone point me in the right direction?

    Jitin, I have a web application running on Apache TomCat 6.0  that uses a JDNI connection for database connectivity everywhere except when I run a report via the viewer page which uses a JDBC connection. I would like to change my reports to use the same JDNI connection. I tried to test this in the CR XI designer by using these settings in the CrConfig.xml but I get theerror  "can't instantiate class".
    Here's the working JDBC settings;
         <JDBCURL>jdbc:oracle:thin:@10.0.1.111:1521:myAppDb</JDBCURL>
         <JDBCClassName>oracle.jdbc.driver.OracleDriver</JDBCClassName>
         <JDBCUserName>AppUser</JDBCUserName>
    Here's the non-working JNDI settings;
    <JNDIURL>//localhost:8080</JNDIURL>
    <JNDIConnectionFactory>org.springframework.jndi.JndiObjectFactoryBean</JNDIConnectionFactory>
    <JNDIInitContext>AppDatabase-ds</JNDIInitContext>
    <JNDIUserName>AppUser</JNDIUserName>
    We are using spring so I used it's factory name. I have the server running locally on my development PC which is why I used localhost as the URL value.
    Here's my application-context-web.xml contents:
      Bean definitions for Data base  -->          
    <bean id="AppDatabaseDS" lazy-init="true" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName"><value>java:comp/env/AppDatabase-ds</value></property>
    </bean>
    and last of all my server.xml contents;
    <GlobalNamingResources>
             <Resource name="AppDatabase-ds"
              auth="Container"
              type="javax.sql.DataSource"
              driverClassName="oracle.jdbc.driver.OracleDriver"
              url="jdbc:oracle:thin:@10.0.1.111:1521:myAppDb"
              username="AppUser"
              password="userpw"
    </GlobalNamingResources>

  • Oracle jdbc setup

    Is there any documentation on recommended jdbc settings for portal running on Oracle 10g or 11g? Specifically, which sources should be XA and the transaction type settings for non-XA drivers?
    Thanks,
    Greg

    Hi Greg
    This folder should have the default jdbc settings recommended for Portal Datasources for both Oracle Drivers or BEA Weblogic Oracle Drivers. They are located at:
    C:\beawlp1032\wlportal_10.3\portal\db\jdbc\oracle_thin
    All other parameters are fine tuned based on the number of db transactions, max concurrent connectioins and how long a single db transaction takes place like that.
    Some customers had better performance using BEA Weblogic Oracle Drivers at the same time others had using Oracle drivers.
    Thanks
    Ravi Jegga

  • JDBC Driver com.ibm.as400.access.AS400JDBCDriver - which port?

    Hi
    We are trying to connect to an AS400 from SAP XI 3.0 using JDBC.
    I am currently getting a Connection Timeout error;
    Error during database connection to the database URL 'jdbc:as400://xxxxxDEV;Fxxxxx.LIB/Fxxxxx.LIB' using the JDBC driver 'com.ibm.as400.access.AS400JDBCDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:as400://xxxxxDEV;Fxxxxx.LIB/Fxxxxx.LIB': SQLException: The application requester cannot establish the connection. (Connection timed out: connect)'
    Can anyone tell me how to find which Port this is trying to connect on?
    We already have successful connections to a different AS400 within our own network, so there is no issues with the driver not being deployed in XI.
    Thanks in advance.

    >
    Andy Cliff wrote:
    > Hi
    > We are trying to connect to an AS400 from SAP XI 3.0 using JDBC.
    >
    > I am currently getting a Connection Timeout error;
    >
    > Error during database connection to the database URL 'jdbc:as400://xxxxxDEV;Fxxxxx.LIB/Fxxxxx.LIB' using the JDBC driver 'com.ibm.as400.access.AS400JDBCDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:as400://xxxxxDEV;Fxxxxx.LIB/Fxxxxx.LIB': SQLException: The application requester cannot establish the connection. (Connection timed out: connect)'
    >
    > Can anyone tell me how to find which Port this is trying to connect on?
    >
    > We already have successful connections to a different AS400 within our own network, so there is no issues with the driver not being deployed in XI.
    >
    > Thanks in advance.
    What are the JDBC settings in CC? The DB that you are trying to connect, have the same dbs version of AS400 that successful connected?

  • Apex Listener config recommendations

    Our DBA is installing Apex Listener 1.1.2.131.15.23 for the first time, and had a question regarding some setup. Right now it's just a stand alone copy. In the JDBC Settings, what are your recommendations for the following settings?
    Initial Pool Size: 3
    Maximum Statements: 10
    Minimum Connections: 1
    Inactivity Timeout: 1800 seconds
    Maximum Connections: 10
    Abandoned Connection Timeout: 900 seconds
    If there is some recommended reading on how to determine the best way to set this up, that would be great.

    Hello Rick,
    it's hard to give you actual values. These settings concern, more or less, your load expectations. The numbers you need are
    - average number of concurrent sessions (work load)
    - maximum number of concurrent sessions (peek load)
    Some settings might as well depend on your applications.
    Recommended reading would be the Table A-1 of the Installation and Developers Guide, where the parameters you picked are described among other configuration parameters.
    Just some thoughts on connection handling:
    The APEX Listener uses a pool of connections to the database that is shared among all users. Usually it would be a waste of resources to have a dedicated connection for each application session, as there are usually times when there's no user activity, e.g. when a user is reading a report. So you want to make the pool size as small as possible without negative impact on your user experience. To achieve this, you may initialize your pool to be able to serve your average work load and allow it to grow to the expected peek. You may want to set the minimum number of connections below that value, so resource consumption is reduced in times of low charge.
    The timeouts concern the reduction of the pool size due to reduced load (inactivity timeout - a connection isn't needed any more) or failures or unexpected long database reaction times (abandoned connection).
    Statements caching can reduce database load and response times, but increases resource consumption of the Listener and may result in inacurate results if cached values are outdated.
    If you have more practical questions on that topic, don't hesitate to ask.
    -Udo

  • Can anyone make my program short? tnx

    i'm new in java programming and have limited knowledge in OOP.. please help me make my code short please please... tnx guys...
    i want to split my program in 2 or more files/classes..
    and can you help me with my looping .. thank you so much...
    my program works fine.. all i want is to make ot shorter coz it almost reach 4k lines...
    here is my code..
    package TXNCNT;
    //imports
    import java.io.*;
    import java.util.*;
    import java.text.*;
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import com.enterprisedt.net.ftp.FTPClient;
    import com.enterprisedt.net.ftp.FTPException;
    import org.apache.log4j.*;
    public class TxnCntMain extends JFrame {
        private static final String DATASOURCECONFIG = "datasource.properties";
        private static String FTP_IPADDRESS = "";
        private static String FTP_USERNAME  = "";
        private static String FTP_PASSWORD  = "";
        private static String FTP_FOLDER    = "";
        private static String FTP_FILE      = "";
        private static String JDBC_DRIVER = "";
        private static String JDBC_URL    = "";
        private static String JDBC_USER   = "";
        private static String JDBC_PWD    = "";
        private static String BRANCHES    = "";
        protected static Category log = Category.getInstance(TxnCntMain.class);
        static {
            try {
                InputStream ins  = (TxnCntMain.class).getResourceAsStream(
                          DATASOURCECONFIG);
                Properties props = new Properties();
                props.load(ins);
                FTP_IPADDRESS = props.getProperty("FTP_IPADDRESS");
                FTP_USERNAME  = props.getProperty("FTP_USERNAME");
                FTP_PASSWORD  = props.getProperty("FTP_PASSWORD");
                FTP_FOLDER    = props.getProperty("FTP_FOLDER");
                FTP_FILE      = props.getProperty("FTP_FILE");
            } catch (IOException ex) {
                ex.printStackTrace();
                TxnCntMain.log.error("Unable to load: " + DATASOURCECONFIG);
        /* Load properties file for JDBC settings */
        static {
            InputStream ins = (TxnCntMain.class).getResourceAsStream(DATASOURCECONFIG);
            Properties props = new Properties();
            try {
                props.load(ins);
            } catch (IOException ex) {
                log.error("Unable to load: " + DATASOURCECONFIG);
                throw new RuntimeException("Unable to load: " + DATASOURCECONFIG);
            JDBC_DRIVER = props.getProperty("JDBC_DRIVER");
            JDBC_URL = props.getProperty("JDBC_URL");
            JDBC_USER = props.getProperty("JDBC_USER");
            JDBC_PWD = props.getProperty("JDBC_PWD");
            BRANCHES = props.getProperty("BRANCHES");
        private static BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) );
        private Connection connect;
        private ControlPanel cp;
        private JTextArea output;
        private JScrollPane textpane;
        private String fromDate = "";
        private String toDate = "";
        private String fDate = "";
        private String tDate = "";
        private Object fromD, fromM, fromY, toD, toM, toY;
        private int FD, TD;
    ////variable used in ControlPanel Class
        private JButton saveButton;
        DecimalFormat dateFormat = new DecimalFormat("00");
        DecimalFormat bCodeFormat = new DecimalFormat("000");
        private int iBCode;
        int rGDep = 0; int rGWith = 0; int rGBP = 0; int rGAO = 0;
        int rGCT = 0;int rGFX = 0;int rGTD = 0;int rTotal = 0;
        public TxnCntMain() {
            super( "MIS REPORT - Branch Transaction Count" );
            Container c = getContentPane();
            output = new JTextArea( 6, 30 );
            output.setEditable(false);
            c.setLayout( new BorderLayout() );
            textpane = new JScrollPane( output );
            c.add( textpane, BorderLayout.CENTER);
    //////// Set up database connection
            try {
                Class.forName(JDBC_DRIVER);
                connect = DriverManager.getConnection( JDBC_URL, JDBC_USER, JDBC_PWD );
                output.append("Connection successful\n"
                            + "Welcome to MIS Report - Branch Transaction Count\n");
                log.info("Connection successful: Welcome to MIS Report - Branch Transaction Count");
            catch ( ClassNotFoundException cnfex ) {
                // process ClassNotFoundExceptions here
                cnfex.printStackTrace();
                output.append("Connection unsuccessful\n" +
                              cnfex.toString() + "\n" );
                log.info("Connection unsuccessful: " + cnfex.toString());
            catch ( SQLException sqlex ) {
                // process SQLExceptions here
                sqlex.printStackTrace();
                output.append( "Connection unsuccessful\n" +
                               sqlex.toString() + "\n" );
                log.info("Connection unsuccessful: " + sqlex.toString());
            catch ( Exception ex ) {
                // process remaining Exceptions here
                ex.printStackTrace();
                output.append( ex.toString() + "\n" );
                log.info(ex.toString());
            // Complete screen layout
            cp = new ControlPanel( connect, output);
            c.add( cp, BorderLayout.NORTH );
            setSize( 650, 450 );
            show();
            try {
                jbInit();
            } catch (Exception ex) {
                ex.printStackTrace();
    ////Inner Class ControLPanel//////////////////////////////////////////////////
        class ControlPanel extends JPanel {
            private JLabel fromDateLabel, fromMonthLabel, fromYearLabel,
                           toDateLabel, toMonthLabel, toYearLabel, from, to;
            private JComboBox fromDateCombo, fromMonthCombo, fromYearCombo,
                              toDateCombo, toMonthCombo, toYearCombo;
            private String days[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
                "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
                "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" };
            private String monthNames[] = { "January", "February", "March",
                    "April", "May", "June", "July", "August", "September",
                    "October", "November", "December" };
            private String years[] = { "1990", "1991", "1992", "1993", "1994",
                      "1995", "1996", "1997", "1998", "1999", "2000", "2001",
                      "2002", "2003", "2004", "2005", "2006", "2007", "2008",
                      "2009", "2010", "2011", "2012", "2013", "2014", "2015",
                      "2016", "2017", "2018", "2019", "2020", "2021", "2022",
                      "2023", "2024", "2025", "2026", "2027", "2028", "2029",
                      "2030", "2031", "2032", "2033", "2034", "2035", "2036",
                      "2037", "2038", "2039", "2040", "2041", "2042", "2043",
                      "2044", "2045", "2046", "2047", "2048", "2049", "2050" };
            public ControlPanel( Connection c, JTextArea t) {
                output = t;
                setLayout( new GridLayout(3,7) );
    ////////////FROM (1st row) /////////////////////////////////////////////////////
                from = new JLabel("  FROM: ");
                add(from);
                fromMonthLabel = new JLabel("Choose Month ",SwingConstants.RIGHT);
                add(fromMonthLabel);
                fromMonthCombo =  new JComboBox(monthNames);
                fromMonthCombo.setMaximumRowCount(12);
                fromMonthCombo.setSelectedIndex(0); //january
                fromM = fromMonthCombo.getSelectedItem();
                fromMonthCombo.addItemListener(
                    new ItemListener() {
                        public void itemStateChanged(ItemEvent e) {
                            fromM = fromMonthCombo.getSelectedItem();
                add(fromMonthCombo);
                fromDateLabel = new JLabel("Choose Date ", SwingConstants.RIGHT);
                add(fromDateLabel);
                fromDateCombo = new JComboBox(days);
                fromDateCombo.setMaximumRowCount(10);
                fromD = fromDateCombo.getSelectedItem();
                fromDateCombo.addItemListener(
                    new ItemListener() {
                        public void itemStateChanged(ItemEvent e) {
                            fromD = fromDateCombo.getSelectedItem();
                add(fromDateCombo);
                fromYearLabel = new JLabel("Choose Year ", SwingConstants.RIGHT);
                add(fromYearLabel);
                fromYearCombo = new JComboBox(years);
                fromYearCombo.setMaximumRowCount(10);
                fromYearCombo.setSelectedIndex(17);     //default selected value is 2007
                fromY = fromYearCombo.getSelectedItem();
                fromYearCombo.addItemListener(
                    new ItemListener() {
                        public void itemStateChanged(ItemEvent e) {
                            fromY = fromYearCombo.getSelectedItem();
                add(fromYearCombo);
    ////////////TO (2nd row) ///////////////////////////////////////////////////////
                to = new JLabel("  TO: ");
                add(to);
                toMonthLabel = new JLabel("Choose Month ",SwingConstants.RIGHT);
                add(toMonthLabel);
                toMonthCombo =  new JComboBox(monthNames);
                toMonthCombo.setMaximumRowCount(12);
                toMonthCombo.setSelectedIndex(0); //january
                toM = toMonthCombo.getSelectedItem();
                toMonthCombo.addItemListener(
                    new ItemListener() {
                        public void itemStateChanged(ItemEvent e) {
                            toM = toMonthCombo.getSelectedItem();
                add(toMonthCombo);
                toDateLabel = new JLabel("Choose Date ", SwingConstants.RIGHT);
                add(toDateLabel);
                toDateCombo = new JComboBox(days);
                toDateCombo.setMaximumRowCount(10);
                toDateCombo.setSelectedIndex(31 - 1); //default selected day is 31
                toD = toDateCombo.getSelectedItem();
                toDateCombo.addItemListener(
                    new ItemListener() {
                        public void itemStateChanged(ItemEvent e) {
                            toD = toDateCombo.getSelectedItem();
                add(toDateCombo);
                toYearLabel = new JLabel("Choose Year ", SwingConstants.RIGHT);
                add(toYearLabel);
                toYearCombo = new JComboBox(years);
                toYearCombo.setMaximumRowCount(10);
                toYearCombo.setSelectedIndex(17);     //default selected year is 2007
                toY = toYearCombo.getSelectedItem();
                toYearCombo.addItemListener(
                    new ItemListener() {
                        public void itemStateChanged(ItemEvent e) {
                            toY = toYearCombo.getSelectedItem();
                add(toYearCombo);
    ////////////3rd row ////////////////////////////////////////////////////////////
                JLabel l1 = new JLabel("     ");
                add(l1);
                JLabel l2 = new JLabel("     ");
                add(l2);
                JLabel l3 = new JLabel("     ");
                add(l3);
                JLabel l4 = new JLabel("     ");
                add(l4);
                JLabel l5 = new JLabel("     ");
                add(l5);
                JLabel l6 = new JLabel("     ");
                add(l6);
    ////////////create an instance of inner class ButtonHandler
    /////////////to use for button event handling
                ButtonHandler handler = new ButtonHandler();
                saveButton = new JButton("Save File");
                saveButton.addActionListener(handler);
                saveButton.setToolTipText("Generate CSV File");
                add(saveButton);
    ////////inner class for button event handling
            private class ButtonHandler implements ActionListener {
                public void actionPerformed(ActionEvent e) {
                    fromDate = dateFormat.format((fromMonthCombo.getSelectedIndex() + 1))
                        + dateFormat.format((fromDateCombo.getSelectedIndex() + 1))
                        + fromY.toString();
                    toDate = dateFormat.format((toMonthCombo.getSelectedIndex() + 1))
                        + dateFormat.format((toDateCombo.getSelectedIndex() + 1))
                        + toY.toString();
                    fDate = fromY.toString()
                        + dateFormat.format((fromMonthCombo.getSelectedIndex() + 1))
                        + dateFormat.format((fromDateCombo.getSelectedIndex() + 1));
                    tDate = toY.toString()
                        + dateFormat.format((toMonthCombo.getSelectedIndex() + 1))
                        + dateFormat.format((toDateCombo.getSelectedIndex() + 1));
                    FD = Integer.parseInt(fDate);
                    TD = Integer.parseInt(tDate);
                    if (FD > TD)  { //check if from date is greater than to date
                        JOptionPane.showMessageDialog(null,
                            "Unable to process... Please check date.",
                            "Error on Date", JOptionPane.ERROR_MESSAGE);
                        output.append("\nUnable to process... Please check date.");
                        log.info("Unable to process... Please check date.");
                    } else {
                        writeToFile();
    ////write to file:
        public void writeToFile() {
            String FILENAME_SUMMARY = "C:/TXNCNT/TotalNoOfTransactionsProcessedPerBranch"
                                  + "_From" + fromD + fromM + fromY
                                  + "To" + toD + toM + toY + ".csv";
            int grandDeposit = 0;
            int grandWithdrawal = 0;
            int grandBP = 0;
            int grandAO = 0;
            int grandCT = 0;
            int grandFX = 0;
            int grandTD = 0;
            int regionalGrandTotal = 0;
            try {
                FileOutputStream outputFile_Summary = new FileOutputStream(FILENAME_SUMMARY, false);
                PrintStream r = null;
                r = new PrintStream(outputFile_Summary);
                r.println("MIS REPORT - Branch Transaction Count");
                r.println(" ");
                r.println("TOTAL # OF TRANSACTIONS PROCESSED PER BRANCH");
                r.println("From: " + fromD + fromM + fromY + " To: " + toD + toM + toY);
                r.println("                                        "
                        + "                                        "
                        + "            TOTAL NUMBER OF TRANSACTIONS");
                r.println("#,BRANCH NAME,DEPOSIT,WITHDRAWALS,BILLS PAYMENT,ACCOUNT OPENING,"
                          + "CASH TURNOVER,FX SALE,TD OPENING,TOTAL");
                r.println("Region 1 GMA 1");
                String FILENAME_REGION = "C:/TXNCNT/" + "Region1_GMA1"
                                          + "_NoOfprocessedTransactionPerBranchPerTeller"
                                          + "_From" + fromD + fromM + fromY
                                          + "To" + toD + toM + toY + ".csv";
                FileOutputStream outputFile_Region = new FileOutputStream(FILENAME_REGION, false);
                PrintStream p = null;
                p = new PrintStream(outputFile_Region);
                p.println("MIS REPORT - Branch Transaction Count");
                p.println("# OF PROCESSED TRANSACTION PER BRANCH PER TELLER");
                p.println("From: " + fromD + fromM + fromY
                          + " To: " + toD + toM + toY);
                p.println("Region 1 GMA 1");
                String sBCode = BRANCHES.substring(0,BRANCHES.indexOf(","));
                int i = BRANCHES.indexOf(",");
                String sTemp = BRANCHES;
                final Vector branches = new Vector(325, 1);
                while (i != sTemp.length()) {
                    branches.addElement(sBCode);
                    sTemp = sTemp.substring(i+1);
                    i = sTemp.indexOf(",");
                    if(i==-1){
                        sBCode = sTemp;
                        branches.addElement(sBCode);
                        i = sTemp.length();
                    }else{
                       sBCode = sTemp.substring(0,sTemp.indexOf(","));
                int iDeposit, iWithdrawals, iBP, iAO, iCT, iFX, iTD, grandTotal;
                for (int b = 0; b < branches.size(); b++) {
                    iBCode = Integer.parseInt(branches.get(b).toString());
                    String code = bCodeFormat.format(iBCode);
                    int gDeposit, gWithdrawal, gBP, gAO, gCT, gFX, gTD;
                    String sTxn = "";
                    grandTotal = 0;
                    final Vector Teller = new Vector(25, 1);
                    gDeposit = 0; gWithdrawal = 0; gBP = 0; gAO = 0; gCT = 0; gFX = 0; gTD = 0;
                    String sBranchName = "";
                    //select branchname from um_branch
                    String sSQL = "SELECT branchname FROM um_branch WHERE "
                                  + "branchcode = " + "'" + code + "'";
                    Statement stmt = connect.createStatement();
                    ResultSet rsQuery = null;
                    rsQuery = stmt.executeQuery(sSQL);
                    if (rsQuery.next()) {
                        sBranchName = rsQuery.getString(1);
                    rsQuery.close();
                    stmt.close();
                    p.println();
                    p.println("Branch Code: " + code + ",Branch Name: " + sBranchName);
                    //retrieve userid's
                    sSQL = "SELECT distinct(userid) FROM bdsarchive.txnjournal WHERE "
                        + "branchno = '" + code + "' AND "
                        + "txndate >= '" + fromDate
                        + "' AND txndate <= '" + toDate + "'";
                    ResultSet rsQuery1 = null;
                    Statement stmt1 = connect.createStatement();
                    rsQuery1 = stmt1.executeQuery(sSQL);
                    int u = 0;
                    String tel = "";
                    String teller = "";
                    String space = "";
                    while (rsQuery1.next()) {
                        tel = rsQuery1.getString(1);
                        teller += "," + tel;
                        Teller.addElement(tel);
                        space += ",";
                        u++;
                    rsQuery1.close();
                    stmt1.close();
                    p.println("Transaction Type,Transaction ID" + teller + ",Total");
                    int tellerTotal[];
                    tellerTotal = new int[u];
                    //DEPOSITS
                    //txnid 1101//
                    int t = 0;
                    sTxn = "";
                    iDeposit = 0;
                    while (t < u) {
                        sSQL = "SELECT count(txnid) FROM bdsarchive.txnjournal WHERE "
                             + "txnid = '1101' AND userid = '" + Teller.get(t) + "' "
                             + "AND branchno = '" + code + "' "
                             + "AND txndate >= '" + fromDate + "' "
                             + "AND txndate <= '" + toDate + "'";
                        ResultSet rsQuery2 = null;
                        Statement stmt2 = connect.createStatement();
                        rsQuery2 = stmt2.executeQuery(sSQL);
                        while (rsQuery2.next()) {
                            sTxn = sTxn + rsQuery2.getString(1) + ",";
                            iDeposit = iDeposit + Integer.parseInt(rsQuery2.getString(1));
                            tellerTotal[t] += Integer.parseInt(rsQuery2.getString(1));
                        rsQuery2.close();
                        stmt2.close();
                        t++;
                    p.println("DEPOSIT,1101 - Peso (SV) Cash with Book," + sTxn + iDeposit);
                    gDeposit += iDeposit;
                    rGDep += iDeposit;
                    //txnid 1102//
                    t = 0;
                    sTxn = "";
                    iDeposit = 0;
                    while (t < u) {
                        sSQL = "SELECT count(txnid) FROM bdsarchive.txnjournal WHERE "
                             + "txnid = '1102' AND userid = '" + Teller.get(t) + "' "
                             + "AND branchno = '" + code + "' "
                             + "AND txndate >= '" + fromDate + "' "
                             + "AND txndate <= '" + toDate + "'";
                        ResultSet rsQuery2 = null;
                        Statement stmt2 = connect.createStatement();
                        rsQuery2 = stmt2.executeQuery(sSQL);
                        while (rsQuery2.next()) {
                            sTxn = sTxn + rsQuery2.getString(1) + ",";
                            iDeposit = iDeposit + Integer.parseInt(rsQuery2.getString(1));
                            tellerTotal[t] += Integer.parseInt(rsQuery2.getString(1));
                        rsQuery2.close();
                        stmt2.close();
                        t++;
                    p.println(",1102 - Peso (SV) OBCK with Book," + sTxn + iDeposit);
                    gDeposit += iDeposit;
                    rGDep += iDeposit;
                    //txnid 1103//
                    t = 0;
                    sTxn = "";
                    iDeposit = 0;
                    while (t < u) {
                        sSQL = "SELECT count(txnid) FROM bdsarchive.txnjournal WHERE "
                             + "txnid = '1103' AND userid = '" + Teller.get(t) + "' "
                             + "AND branchno = '" + code + "' "
                             + "AND txndate >= '" + fromDate + "' "
                             + "AND txndate <= '" + toDate + "'";
                        ResultSet rsQuery2 = null;
                        Statement stmt2 = connect.createStatement();
                        rsQuery2 = stmt2.executeQuery(sSQL);
                        while (rsQuery2.next()) {
                            sTxn = sTxn + rsQuery2.getString(1) + ",";
                            iDeposit = iDeposit + Integer.parseInt(rsQuery2.getString(1));
                            tellerTotal[t] += Integer.parseInt(rsQuery2.getString(1));
                        rsQuery2.close();
                        stmt2.close();
                        t++;
                    p.println(",1103 - Peso (SV) DDMC with Book," + sTxn + iDeposit);
                    gDeposit += iDeposit;
                    rGDep += iDeposit;
                    //txnid 1104//
                    t = 0;
                    sTxn = "";
                    iDeposit = 0;
                    while (t < u) {
                        sSQL = "SELECT count(txnid) FROM bdsarchive.txnjournal WHERE "
                             + "txnid = '1104' AND userid = '" + Teller.get(t) + "' "
                             + "AND branchno = '" + code + "' "
                             + "AND txndate >= '" + fromDate + "' "
                             + "AND txndate <= '" + toDate + "'";
                        ResultSet rsQuery2 = null;
                        Statement stmt2 = connect.createStatement();
                        rsQuery2 = stmt2.executeQuery(sSQL);
                        while (rsQuery2.next()) {
                            sTxn = sTxn + rsQuery2.getString(1) + ",";
                            iDeposit = iDeposit + Integer.parseInt(rsQuery2.getString(1));
                            tellerTotal[t] += Integer.parseInt(rsQuery2.getString(1));
                        rsQuery2.close();
                        stmt2.close();
                        t++;
                    p.println(",1104 - Peso (SV) PNBC with Book," + sTxn + iDeposit);
                    gDeposit += iDeposit;
                    rGDep += iDeposit;
                    //txnid 1105//
                    t = 0;
                    sTxn = "";
                    iDeposit = 0;
                    while (t < u) {
                        sSQL = "SELECT count(txnid) FROM bdsarchive.txnjournal WHERE "
                             + "txnid = '1105' AND userid = '" + Teller.get(t) + "' "
                             + "AND branchno = '" + code + "' "
                             + "AND txndate >= '" + fromDate + "' "
                             + "AND txndate <= '" + toDate + "'";
                        ResultSet rsQuery2 = null;
                        Statement stmt2 = connect.createStatement();
                        rsQuery2 = stmt2.executeQuery(sSQL);
                        while (rsQuery2.next()) {
                            sTxn = sTxn + rsQuery2.getString(1) + ",";
                            iDeposit = iDeposit + Integer.parseInt(rsQuery2.getString(1));
                            tellerTotal[t] += Integer.parseInt(rsQuery2.getString(1));
                        rsQuery2.close();
                        stmt2.close();
                        t++;
                    p.println(",1105 - Peso (SV) FDR with Book," + sTxn + iDeposit);
                    gDeposit += iDeposit;
                    rGDep += iDeposit;
                    //txnid 1106//
                    t = 0;
                    sTxn = "";
                    iDeposit = 0;
                    while (t < u) {
                        sSQL = "SELECT count(txnid) FROM bdsarchive.txnjournal WHERE "
                             + "txnid = '1106' AND userid = '" + Teller.get(t) + "' "
                             + "AND branchno = '" + code + "' "
                             + "AND txndate >= '" + fromDate + "' "
                             + "AND txndate <= '" + toDate + "'";
                        ResultSet rsQuery2 = null;
                        Statement stmt2 = connect.createStatement();
                        rsQuery2 = stmt2.executeQuery(sSQL);
                        while (rsQuery2.next()) {
                            sTxn = sTxn + rsQuery2.getString(1) + ",";
                            iDeposit = iDeposit + Integer.parseInt(rsQuery2.getString(1));
                            tellerTotal[t] += Integer.parseInt(rsQuery2.getString(1));
                        rsQuery2.close();
                        stmt2.close();
                        t++;
                    p.println(",1106 - Peso (SV) PNBC Cross Check with Book," + sTxn + iDeposit);
                    gDeposit += iDeposit;
                    rGDep += iDeposit;
                     //txnid 1107//
                    t = 0;
                    sTxn = "";
                    iDeposit = 0;
                    while (t < u) {
                        sSQL = "SELECT count(txnid) FROM bdsarchive.txnjournal WHERE "
                             + "txnid = '1107' AND userid = '" + Teller.get(t) + "' "
                             + "AND branchno = '" + code + "' "
                             + "AND txndate >= '" + fromDate + "' "
                             + "AND txndate <= '" + toDate + "'";
                        ResultSet rsQuery2 = null;
                        Statement stmt2 = connect.createStatement();
                        rsQuery2 = stmt2.executeQuery(sSQL);
                        while (rsQuery2.next()) {
                            sTxn = sTxn + rsQuery2.getString(1) + ",";
                            iDeposit = iDeposit + Integer.parseInt(rsQuery2.getString(1));
                            tellerTotal[t] += Integer.parseInt(rsQuery2.getString(1));
                        rsQuery2.close();
                        stmt2.close();
                        t++;
                    p.println(",1107 - Peso (SV) Credit Memo with Book," + sTxn + iDeposit);
                    gDeposit += iDeposit;
                    rGDep += iDeposit;
                     //txnid 1110//
                    t = 0;
                    sTxn = "";
                    iDeposit = 0;
                    while (t < u) {
                        sSQL = "SELECT count(txnid) FROM bdsarchive.txnjournal WHERE "
                             + "txnid = '1110' AND userid = '" + Teller.get(t) + "' "
                             + "AND branchno = '" + code + "' "
                             + "AND txndate >= '" + fromDate + "' "
                             + "AND txndate <= '" + toDate + "'";
                        ResultSet rsQuery2 = null;
                        Statement stmt2 = connect.createStatement();
                        rsQuery2 = stmt2.executeQuery(sSQL);
                        while (rsQuery2.next()) {
                            sTxn = sTxn + rsQuery2.getString(1) + ",";
                            iDeposit = iDeposit + Integer.parseInt(rsQuery2.getString(1));
                            tellerTotal[t] += Integer.parseInt(rsQuery2.getString(1));
                        rsQuery2.close();
                        stmt2.close();
                        t++;
                    p.println(",1110 - Peso (SV) Cash no Book," + sTxn + iDeposit);
                    gDeposit += iDeposit;
                    rGDep += iDeposit;
                    //txnid 1111//
                    t = 0;
                    sTxn = "";
                    iDeposit = 0;
                    while (t < u) {
                        sSQL = "SELECT count(txnid) FROM bdsarchive.txnjournal WHERE "
                             + "txnid = '1111' AND userid = '" + Teller.get(t) + "' "
                             + "AND branchno = '" + code + "' "
                             + "AND txndate >= '" + fromDate + "' "
                             + "AND txndate <= '" + toDate + "'";
                        ResultSet rsQuery2 = null;
                        Statement stmt2 = connect.createStatement();
                        rsQuery2 = stmt2.executeQuery(sSQL);
                        while (rsQuery2.next()) {
                            sTxn = sTxn + rsQuery2.getString(1) + ",";
                            iDeposit = iDeposit + Integer.parseInt(rsQuery2.getString(1));
                            tellerTotal[t] += Integer.parseInt(rsQuery2.getString(1));
                        rsQuery2.close();
                        stmt2.close();
                        t++;
                    p.println(",1111 - Peso (SV) OBCK no Book," + sTxn + iDeposit);
                    gDeposit += iDeposit;
                    rGDep += iDeposit;
                    //txnid 1112//
                    t = 0;
                    sTxn = "";
                    iDeposit = 0;
                    while (t < u) {
                        sSQL = "SELECT count(txnid) FROM bdsarchive.txnjournal WHERE "
                             + "txnid = '1112' AND userid = '" + Teller.get(t)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Well expanding on before.
    All this can be ripped out and put in a different method
    t = 0;
                    sTxn = "";
                    iDeposit = 0;
                    while (t < u) {
                        sSQL = "SELECT count(txnid) FROM bdsarchive.txnjournal WHERE "
                             + "txnid = '1104' AND userid = '" + Teller.get(t) + "' "
                             + "AND branchno = '" + code + "' "
                             + "AND txndate >= '" + fromDate + "' "
                             + "AND txndate <= '" + toDate + "'";
                        ResultSet rsQuery2 = null;
                        Statement stmt2 = connect.createStatement();
                        rsQuery2 = stmt2.executeQuery(sSQL);
                        while (rsQuery2.next()) {
                            sTxn = sTxn + rsQuery2.getString(1) + ",";
                            iDeposit = iDeposit + Integer.parseInt(rsQuery2.getString(1));
                            tellerTotal[t] += Integer.parseInt(rsQuery2.getString(1));
                        rsQuery2.close();
                        stmt2.close();
                        t++;
                    p.println(",1104 - Peso (SV) PNBC with Book," + sTxn + iDeposit);
                    gDeposit += iDeposit;
                    rGDep += iDeposit;Then just call the method with the txnid value. So perhaps a List ( ArrayList) of txnid values and a for loop.
    Boom. There's a great chunk of repetitive code gone.
    Then the next step in refactoring to different classes is to seperate out all the pieces.
    Put the FTP bits in to one class.
    Put the database and processing stuff into another class.
    Put the report writing into another class.
    That would be a good start.

Maybe you are looking for