Trim a setString

Hello there!
I am using SQLServer 2000 and I want to update a table which has a varchar column and it leads right spaces, in spite of I am using a trim before updating, Waht is worog? How can I trim a setString?
Table: Country
Fields:
- id: numeric, not NULL
- name: varchar(50)
public void update(int id, String name) throws SQLException {
try {
this.dbConn = daoFac.getConn();
String sqlStr = "UPDATE " + res.getString("country") + " SET name = ? WHERE id = ?";
prStm = dbConn.prepareStatement(sqlStr, ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
prStm.setString(1, name.trim()); //It does not work!!!
prStm.setInt(2, id);
prStm.execute();
finally {
daoFac.closeConn();
When I try with BURUNDI, it appears on DB as "BURUNDI . . . . . . . . . " with as many right spaces as it needs to reach 50 characters.
How can I fix it without a trigger nor store procedures. Is ther any way form Java?
Thanks a lot
LJ

Maybe it is just because it is the end of the day but I do not see the problem.
Of course if you open the table and check the values you will see trailing spaces. Column don't just shrink and expand as you enter values. It has a fixed column width of 50 characters.
When you retrieve the value from the database through a SQL statement it will only return the relevant (used) values. Like in this example if you later retrieve the value through a select statement it will only return BURUNDI and not the unused spaces at the end of the column.
I am understanding this correct, right? You want the trailing spaces in the database table to not be there, right? Not going to happen my son.
But maybe I am just not getting the issue and you just have to explain it better to me cause I really do want to help.

Similar Messages

  • File upload to HANA Database using UI5

    Hi ,
    I am using UI5 fileuploader to upload the data into HANA table.I have followed the blogs to upload the files into table.Created xsjs query to read file data and insert data in the table.below is the code snippet.if i follw this method,if no of records to be uploaded are more million records will there be any performance issue.Are there any other methods to upload data from UI5 to HANA table.
    function escape(v1)  
      var v2 = v1.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); 
      return v2;  
    function upLoadFile()
      var conn = $.db.getConnection();
      var filename = $.request.parameters.get("file_name");
      var query = "insert into \"SCHEMA\".\"table\" values (?,?,?,?,?,?,?,?,?,?,?,?,?)";
      var pstmt = conn.prepareCall(query);
      if($.request.entities.length>0)
      var file_body = $.request.entities[0].body.asString(); 
      var allTextLines = file_body.trim().split(/\r\n|\n/);
      var lines;
      var entries;  
      var pos;
      var c;
      var col;  
      for (lines=1; lines<allTextLines.length; lines++)   
      entries = allTextLines[lines].trim().split('\t'); 
      col = entries.splice(0,13);   
      pstmt.setString(1,escape(col[0].trim())); 
                    pstmt.setString(2,escape(col[1].trim())); 
                    pstmt.setString(3,escape(col[2].trim())); 
                    pstmt.setString(4,escape(col[3].trim())); 
                    pstmt.setString(5,escape(col[4].trim())); 
                    pstmt.setString(6,escape(col[5].trim())); 
                    pstmt.setString(7,escape(col[6].trim())); 
                    pstmt.setDecimal(8,parseFloat(col[7],2)); 
                    pstmt.setDecimal(9,parseFloat(col[8],2)); 
                    pstmt.setString(10,escape(col[9].trim())); 
                    pstmt.setString(11,escape(col[10].trim()));
                    pstmt.setString(12,escape(col[11].trim())); 
                    pstmt.setString(13,escape(col[12].trim()));
             pstmt.addBatch();
      pstmt.execute();
      pstmt.close();          
      conn.commit();            
      conn.close();         
    var vCmd = $.request.parameters.get('CMD');
    switch (vCmd) {
    case "INSERT": upLoadFile(); break;

    Hi Pavani,
    Keeping millions of records in the prepared statement object (yes it is saved in the memory ) does not look good. Can't we trigger pstmt.execute(); for a 1000 records block ?
    Sreehari

  • Prepared Statement error, someone plz help

    strQuery = qryProvide.supplyNotReceivedQuery();
    logObject.log("CompDataProvider","supplyNotReceivedRecords",strQuery, XMLMON_Constants.LOG_DEBUG);
    stmtRestSchema = con.prepareStatement(strQuery);
    stmtRestSchema.setString(1,loadingPoint.trim());
    stmtRestSchema.setString(2,schemaName.trim());
    stmtRestSchema.setInt(3, process);
    stmtRestSchema.setString(4,strFromDt.trim());
    rsRestSchema = stmtRestSchema.executeQuery();
    if(rsRestSchema.next()){
         String proid = rsRestSchema.getString(XMLMON_Constants.MON_LOGS_PROCESS_ID);
         int refid = rsRestSchema.getInt(XMLMON_Constants.MON_LOGS_REFID);
    } else {
         String strQry = qryProvide.supplyNotRecQuery();
         logObject.log("CompDataProvider","supplyNotReceivedRecords",strQry, XMLMON_Constants.LOG_DEBUG);
         stmtData = con.prepareStatement(strQry.toString());
         stmtData.clearParameters();
         stmtData.setString(1, loadingPoint.trim());
         stmtData.setString(2, schemaName.trim());
         stmtData.setInt(3, process);
         stmtData.setString(4,strFromDt.trim());
         /***************** Its Reaching here/
         rsData = stmtData.executeQuery(strQuery);
         /***************** Its failing here throwing exception not all variables bound/
         if(!( rsData.next() ) ){
         //     do something here
         } else{
              System.out.println("do nothing");
         rsData.close();
         stmtData.close();
    rsRestSchema.close();
    stmtRestSchema.close();
    Can anyone help me in solving the error. i have found the error where and i m not able to find why. please i need help.

    Could you print out the query, e.g. strQry, I
    think the problem lies in the Query string.

  • ResultSet.next() and resultset.islast() problem

    I have query which returns 10 records. I run the using preparedStatement. When i use the while(resultSet.next()), the loop runs untill 10 records and after that when it come to the while check it hangs.
    Sample code
    pstmt= conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    rs = pstmt.executeQuery();
    while (rsAccessNoEq.next()) {...
    Then i added the code in the while loop
    if(rs.isLast()){
    return;
    For the first iteration itself the theisLast() is true and it terminates from the loop.
    Please help me

    public class ISP {
         private GFA gestorFic = null;
         private GCA gestorCad = null;
         private GBDAgestor = null;
         private String path = null;
         ServiceProcessVO javaIntra = null;
         ServiceProcessVO javaIntra1 = null;
         ServiceProcessVO javaIntra2 = null;
         ServiceProcessVO javaIntra3 = null;
         ArrayList dataList = null;
         List dataFile = null;
         ArrayList dataList1 = null;
         ArrayList dataList2 = null;
         ArrayList dataList3 = null;          
         public final void iP() throws SQLException,
         MCEA {
         ResultSet rsIntraHq = null;
              Connection connIntraHq = null;
              PreparedStatement pstmtIntraHq = null;
              ResultSet rsIntraFlow = null;
              Connection connIntraFlow = null;
              PreparedStatement pstmtIntraFlow = null;
              ResultSet rsEqNoAccess = null;
              Connection connEqNoAccess = null;
              PreparedStatement pstmtEqNoAccess = null;
              ResultSet rsAccessNoEq = null;
              Connection connAccessNoEq = null;
              PreparedStatement pstmtAccessNoEq = null;
              ResultSet rsFlowHqAccess = null;
              Connection connFlowHqAccess = null;
              PreparedStatement pstmtFlowHqAccess = null;
              dataList = new ArrayList();          
              dataFile = new ArrayList();
              System.out.println("At the begining :"+now() );
              dataFile = gestorFic.leerArchivo(path, file);
              System.out.println("After first step :"+now() );
              int size1 = dataFile.size();
              try {
                   connAccessNoEq = gestor.getConnection();
                   javaIntra = new ServiceProcessVO();
                   pstmtAccessNoEq = connAccessNoEq
                   .prepareStatement(ConsultasAssets.INTRA_ACCESS_NOEQ);
                             //ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
                   pstmtAccessNoEq.setString(1, oti);
                   pstmtAccessNoEq.setString(2, oti);
                   pstmtAccessNoEq.setString(3, oti);
                   rsAccessNoEq = pstmtAccessNoEq.executeQuery();
                   //int k = rsAccessNoEq.TYPE_SCROLL_SENSITIVE;
                   int i = 0;
                   //rsAccessNoEq.last();
                   while (rsAccessNoEq.next()) {
                        i++; System.out.println("Begin of loop:"+i);
                        javaIntra = populatedata(rsAccessNoEq, true);
                        dataList.add(javaIntra);
                        // Flow Hq Access
                        try {
                             connFlowHqAccess = gestor.getConnection();
                             javaIntra1 = new ServiceProcessVO();
                             pstmtFlowHqAccess = connFlowHqAccess
                             .prepareStatement(ConsultasAssets.HQ_ACCESS);
                             pstmtFlowHqAccess.setString(1, javaIntra
                                       .getCTASOCIACION().trim());
                             pstmtFlowHqAccess.setString(2, rsAccessNoEq.getString(1)
                                       .trim());
                             pstmtFlowHqAccess.setString(3, rsAccessNoEq.getString(3)
                                       .trim());
                             pstmtFlowHqAccess.setString(4,oti);
                             pstmtFlowHqAccess.setString(5,oti);
                             pstmtFlowHqAccess.setString(6,oti);
                             rsFlowHqAccess = pstmtFlowHqAccess.executeQuery();
                             while (rsFlowHqAccess.next()) {
                                  javaIntra1 = populatedata(rsFlowHqAccess, false);
                                  dataList.add(javaIntra1);
    //                         if(rsAccessNoEq.isAfterLast()){
    //                              return;
                        } catch (SQLException se) {
                             MCLA.logFatel(ClassNameAssets
                                       .getQualifiedClassName()
                                       + ": "
                                       + ClassNameAssets.getLineNumber()
                                       + ": "
                                       + "Error Occurred in HQ_ACCESS: "
                                       + se.getMessage());
                             throw new MigracionCommonExceptionAssets(se.getMessage());
                        } finally {
                             pstmtFlowHqAccess.close();
                             if (rsFlowHqAccess != null) {
                                  rsFlowHqAccess.close();
                             //gestor.releaseConn(connFlowHqAccess);
         private SPVOpopulatedata(ResultSet rsCpProcess, boolean modify)
         throws SQLException {
              SPVOjavaIntra = new ServiceProcessVO();
              if (rsCpProcess.getString(ConstantesAssets.NU) != null
                        && !rsCpProcess.getString(ConstantesAssets.NU)
                        .equalsIgnoreCase(ConstantesAssets.BLANK))
                   javaIntra.setNU(rsCpProcess.getString(
                             ConstantesAssets.NU).trim());
              if (rsCpProcess.getString(ConstantesAssets.NU_ASO) != null
                        && !rsCpProcess.getString(ConstantesAssets.NU_ASO)
                        .equalsIgnoreCase(ConstantesAssets.BLANK))
                   javaIntra.setNU_ASO(rsCpProcess.getString(
                             ConstantesAssets.NU_ASO).trim());
              // HashTable logic to increament value for CTASOCIACION Start
              if (modify == true) {
                   if (rsCpProcess.getString(ConstantesAssets.CTASOC) != null
                             && !rsCpProcess.getString(ConstantesAssets.CTASOC)
                             .equalsIgnoreCase(ConstantesAssets.BLANK)) {
                        char cha = ConstantesAssets.A;
                        if (tempMap.get(javaIntra.getNU()) != null) {
                             cha = tempMap.get(javaIntra.getNU()).toString()
                             .charAt(0);
                             cha++;
                        tempMap.put(javaIntra.getNU(), Character
                                  .toString(cha));
                        javaIntra.setCTASOCIACION(((rsCpProcess
                                  .getString(ConstantesAssets.CTASOC).trim()) + cha)
                                  .trim());
              } else {
                   javaIntra.setCTASOCIACION(rsCpProcess.getString(
                             ConstantesAssets.CTASOC).trim());
              // HashTable logic to increament value for CTASOCIACION End
              if (rsCpProcess.getString(ConstantesAssets.CCC) != null
                        && !rsCpProcess.getString(ConstantesAssets.CCC)
                        .equalsIgnoreCase(ConstantesAssets.BLANK))
                   javaIntra.setCCC(rsCpProcess.getString(
                             ConstantesAssets.CCC).trim());
              if (rsCpProcess.getString(ConstantesAssets.FIV1) != null
                        && !rsCpProcess.getString(ConstantesAssets.FIV1)
                        .equalsIgnoreCase(ConstantesAssets.BLANK))
                   javaIntra.setFIV(rsCpProcess.getString(
                             ConstantesAssets.FIV1).trim());
              if (rsCpProcess.getString(ConstantesAssets.FFV) != null
                        && !rsCpProcess.getString(ConstantesAssets.FFV)
                        .equalsIgnoreCase(ConstantesAssets.BLANK))
                   javaIntra.setFFV(rsCpProcess.getString(
                             ConstantesAssets.FFV).trim());
              if (rsCpProcess.getString(ConstantesAssets.ES) != null
                        && !rsCpProcess.getString(ConstantesAssets.ES)
                        .equalsIgnoreCase(ConstantesAssets.BLANK))
                   javaIntra.setES(rsCpProcess.getString(
                             ConstantesAssets.ES).trim());
              javaIntra.setI(ConstantesAssets.N);
              javaIntra.setN(ConstantesAssets.BLANK);
              javaIntra.setC(ConstantesAssets.BLANK);
              javaIntra.setCO(ConstantesAssets.BLANK);
              javaIntra.setFI(ConstantesAssets.BLANK);
              return javaIntra;
    Please see the code
    Siva

  • Using MS Access as backend in Webdynpro Application

    hi guys,
    I am creating a application in webdynpro in which i want to use MS Access as Backend, so can u please tell how to use MS Access as backend.
    What all needs to be done and where the database file needs to be stored etc. please give me all the details...
    thanks in advance
    Gaurav Makin

    Hi Gaurav,
    It is pretty easy to use the MSAccess as a  back end from the webdynpro applications. Take the driver as a JDBC-ODBBC driver and  creat the alias name for the  database  server  to use as a data source.Select the model as a Beanmodel  while creating a model in the Webdynpro explorer.
    please  find the below code which will help you lot.
    Please let me know if you need any further information.
    package com.accenture.radar.project;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    @author suvarna.chittoor
    To change the template for this generated type comment go to
    Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    public class ProjectBean {
         private String name;
         private String description;
         private String du;
         private String saveOrUpdate;
         static DataSource dataSource;
         private Connection connection;
         private ResultSet rs;
         private ArrayList duArrayList =new ArrayList();
         private ArrayList projectArrayList =new ArrayList();
         public ProjectBean()
              try
                   //code to look up the datasource
                   InitialContext initialContext = new InitialContext();
                   dataSource = (DataSource)initialContext.lookup("jdbc/aliasforradar");
              catch(Exception e)
                   System.err.print("Error Message"+e.getMessage());
         public static Connection getConnection() throws SQLException, ClassNotFoundException
              System.err.println("In Get Connection");
              java.sql.Connection connection = null ;
              try
                   connection = dataSource.getConnection();
              catch (SQLException e)
                   System.err.println(e.getMessage());     
                   throw e;                         
              System.err.println("After getting Connection from the datasource");
              return connection;
         public void getDUInformation()throws SQLException, ClassNotFoundException
                        connection = getConnection();
                        PreparedStatement ps= connection.prepareStatement("select distinct name from du");
                        rs=ps.executeQuery();
                             while(rs.next())
                                  duArrayList.add(rs.getString("name"));
                        ps.close();
                        connection.close();
         public void saveProjectDetails() throws SQLException, ClassNotFoundException
                   Connection connection = null;
                             if(saveOrUpdate.equalsIgnoreCase("Save"))
                                  connection = getConnection();
                                  PreparedStatement ps =
                                       connection.prepareStatement(
                                            "insert into project values(?,?,?)");
                                       ps.setString(1, getName());
                                       ps.setString(2, getDescription());
                                       ps.setString(3, getDu());
                                       ps.executeUpdate();
                                       connection.close();
                                       ps.close();
                             else
                                  connection = getConnection();
                                  PreparedStatement ps =connection.prepareStatement("update project set du=?,description=? where name='"name.trim()"'");
                                  ps.setString(1,du);
                                  ps.setString(2,description);                         
                                  ps.executeUpdate();                         
                                  connection.close();
                                  ps.close();
         public void getProjectDetails() throws SQLException, ClassNotFoundException
                             Connection connection = null;
                                  connection = getConnection();
                                  PreparedStatement ps=connection.prepareStatement("select name,description,du from project");
                                  rs=ps.executeQuery();
                                       while(rs.next())
                                            Project_HelperClass proj= new Project_HelperClass();
                                            proj.setName(rs.getString("name"));
                                            proj.setDescription(rs.getString("Description"));
                                            proj.setDu(rs.getString("du"));
                                            projectArrayList.add(proj);
                                    ps.close();
                                    connection.close();
         public void getProjectInformation()
                   throws SQLException, ClassNotFoundException {
                   Connection connection = null;
                   connection = getConnection();
                   PreparedStatement ps =
                   connection.prepareStatement("select description,du from project where name='"name"'");
                   rs = ps.executeQuery();
                     while(rs.next())
                        this.description=rs.getString("description");
                        this.du=rs.getString("du");
                      connection.close();
                      ps.close();
    @return
              public String getDescription() {
                   return description;
         public void deleteProject() throws SQLException, ClassNotFoundException
             Connection connection = null;
              connection = getConnection();
              PreparedStatement ps=connection.prepareStatement("delete from sme_support where project = '"name"'");
              ps.executeUpdate();
              PreparedStatement ps1=connection.prepareStatement("delete from wbse where project = '"name"'");
              ps1.executeUpdate();
              PreparedStatement ps2=connection.prepareStatement("delete from supervisor where project = '"name"'");
              ps2.executeUpdate();
              PreparedStatement ps3=connection.prepareStatement("delete from du_lead where project = '"name"'");
              ps3.executeUpdate();
              PreparedStatement ps4=connection.prepareStatement("delete from project where name = '"name"'");
              ps4.executeUpdate();
              connection.close();
              ps.close();     
              ps1.close();
              ps2.close();
              ps3.close();
              ps4.close();          
    @return
         public String getDu() {
              return du;
    @return
              public ArrayList getDuArrayList() {
                   return duArrayList;
    @return
         public String getName() {
              return name;
    @param string
              public void setDescription(String string) {
                   description = string;
    @param string
         public void setDu(String string) {
              du = string;
    @param list
              public void setDuArrayList(ArrayList list) {
                   duArrayList = list;
    @param string
         public void setName(String string) {
              name = string;
    @return
         public ArrayList getProjectArrayList() {
              return projectArrayList;
    @param list
         public void setProjectArrayList(ArrayList list) {
              projectArrayList = list;
    @return
         public String getSaveOrUpdate() {
              return saveOrUpdate;
    @param string
         public void setSaveOrUpdate(String string) {
              saveOrUpdate = string;
    Thanks and regards
    Ratnakar reddy alwala

  • What is a better approach, batch or prepared statement?

    Hi,
    In my application, the user account property will be retrieved from DB and the last login time will be updated after a successful sign on. There are two query statements in this procedure; select and update. What is a better approach in JDBC to deal with the two queries: batch or prepared statement?
    Thanks.

    Hi, Duffy,
    Thanks for your input.
    I would like to use PreparedStatement with batch update. From my reading, however, it is not suitable to use PreparedStatement with batch update. At less, I haven't see a single example on the tutorial or article sections of this site. I am not sure the following is valid or not:
                   stmt = connection.prepareStatement(INSERT_SMT_QUERY_STR);
                   stmt.setLong(1, details.getRegardID());
                   stmt.setLong(2, details.getWriterID());
                   stmt.setInt(3, details.getVisibility());
                   stmt.setString(4, details.getSubject().trim());
                   stmt.setString(5, details.getContent().trim());
    stmt.addBatch() <-- what goes into here?

  • Bug? EJB method Return Value and Client Catch the Exception?

    oc4j 9.0.3 on the windows 2000
    I write a Stateless Session Bean named SB1 ,
    and define application exception.
    The Code as follow:
    public class AppErrorException extends Exception
    public interface SB1 extends EJBObject
    public String getMemono(String sysID, String rptKind, String parentMemono)
    throws RemoteException, AppErrorException;
    public class SB1Bean implements SessionBean
    public String getMemono(String sysID, String rptKind, String parentMemono)
    throws RemoteException, AppErrorException
    throw new AppErrorException("Error in getMemono");
    public class SB1TestClient
    try
    memomo= sb1.getMemono(.....);
    catch(AppErrorException ae)
    ae.printStackTrace();
    I found a bug.
    If SB1.getMemono() throws the AppErrorException, but SB1TestClient will not catch any Exception.
    It is not normal!!!!
    [cf]
    But If I convert "public String getMemono(...)" into "public void getMemono(...)",
    When SB1.getMemono() throws the AppErrorException, but SB1TestClient will catch any Exception.
    It is normal.

    getMemono(.......)'s code as follow:
    public String getMemono(String sysID, String rptKind, String parentMemono)
    throws AppErrorException
    log("getMemono("+sysID+", "+rptKind+", "+parentMemono+")");
    Connection connection= null;
    CallableStatement statement = null;
    String memono= "";
    short retCode= -1;
    String retMsg= "";
    try
    String sql= this.CALL_SPGETMEMONO;
    connection = ResourceAssistant.getDBConnectionLocal("awmsDS");
    statement= connection.prepareCall(sql);
    statement.setString(1, sysID.trim());
    statement.setString(2, rptKind.trim());
    statement.setString(3, parentMemono.trim());
    statement.registerOutParameter(4, java.sql.Types.VARCHAR);
    statement.registerOutParameter(5, java.sql.Types.SMALLINT);
    statement.registerOutParameter(6, java.sql.Types.VARCHAR);
    statement.executeQuery();
    retCode= statement.getShort(5);
    retMsg= statement.getString(6);
    log("retCode="+retCode);
    log("retMsg="+retMsg);
    if (retCode==AppConfig.SHORT_SP_RETCODE_FAILED)
    log("retCode==AppConfig.SHORT_SP_RETCODE_FAILED");
    this.sessionContext.setRollbackOnly();
    throw new AppErrorException(retMsg);
    memono= statement.getString(4);
    log("memono="+memono);
    if (rptKind.trim().length()<6)
    log("rptKind.trim().length()<6");
    this.sessionContext.setRollbackOnly();
    throw new AppErrorException("rptKind.trim().length()<6");
    memono= "SS";
    catch (AppErrorException ae)
    log("catch(AppErrorException ae)");
    throw ae;
    //throw new EJBException(ae.getErrMsg());
    catch (Exception e)
    log("catch (Exception e)");
    this.sessionContext.setRollbackOnly();
    throw new AppErrorException(IExceptionConst.ERR_MSG_SYSMEMONO_00000, e.toString());
    //throw new EJBException(IExceptionConst.ERR_MSG_SYSMEMONO_00000+", "+e.toString());
    finally
    log("this.sessionContext.getRollbackOnly()="+this.sessionContext.getRollbackOnly());
    ResourceAssistant.cleanup(connection,statement);
    return memono;

  • Apostrophes returned from getText() causing SQL errors

    I have a seemingly elementary problem, but I can't seem to come up with a simple solution. Look at the following line of code:
    s.execute("insert into Requests values ('"+field5.getText().trim()+"','"+tempTime+"','"+tempTime+":  PROBLEM OPENED\n\n"+tempTime+":  "+area.getText()+"','','Open');");I am using this to add a record to my SQL table. However, whenever there is an apostrophe (') read from the area.getText(), that causes the SQL statement to be improperly executed. I understand why it's causing a problem, but I was wondering if there was a simple solution for it. Or is my only recourse to have my application check every single character in the JTextArea area for apostrophes and insert backslashes before the SQL statement is executed? Thanks for the help!

    Well I decided to go with the PreparedStatement route, but I still seem to be having the same problem. Here is my code now:
         private static PreparedStatement s;
         private static Connection con;
         private String tempTime;
         try
                      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                      String dataSourceName = "Mail_List";
                      String dbURL = "jdbc:odbc:" + dataSourceName;
                      con = DriverManager.getConnection(dbURL,"","");
                   Calendar cal = Calendar.getInstance();
                   tempTime = cal.getTime().toString().trim();
                   String query = "INSERT INTO Requests VALUES ('?','?','?','','Open')";
                   s = con.prepareStatement(query);
                   s.setString(1, field5.getText().trim());
                   s.setString(2, tempTime);
                   s.setString(3, tempTime+":  PROBLEM OPENED\n\n"+tempTime+":  "+area.getText());
                   s.executeQuery();
                   s.close();
                   con.close();
              }Do you guys see anything wrong?

  • Hashtable sorting

    I have a Hashtable that I want to sort according to the "values" and then comapre the hshtable with the array of strings to get a new hashtable with the unique values.Pl let me know if somebody has come across similar issue..
    Thanks ..

    I have this code I need to sort but the problem is that i need to add an hashtable along with the vector. So there they run in sync. The reason in doing this is to bypass the primary key. The program deals with many cases. The ones i am sorting is missing files and duplicate files. I have sorted out the missing files with a vector. Note this is a long code. So you are warned. I had trouble sorting the missing files bit. I only added 8 lines
    package com.whw;
    //import com.intex.*;
    //import com.Kidson.*;
    import com.sql.*;
    import com.web.*;
    import com.whw.*;
    import java.sql.SQLException;
    import java.util.*;
    import java.lang.*;
    import java.io.*;
    import java.text.*;
    import java.sql.*;
    //     J2EE     API
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.Hashtable; //added
    import java.util.Enumeration; //added
    //     Oracle API
    import oracle.sql.*;
    import oracle.jdbc.driver.OracleResultSet;
    import oracle.jdbc.driver.*;
    import oracle.jdbc.OraclePreparedStatement;
    //     Java Excel API
    import jxl.*;
    import jxl.format.*;
    import jxl.write.*;
    import jxl.biff.*;
    import jxl.read.biff.*;
    import jxl.write.biff.*;
    public class WHWBean{
         // for customer info
         public int WHW_Right=0;
         public int Staff_Right=0;
        public String status=null;
        public String usrcod=null;
        public String lognam=null;
        public String ErrFlg=null;
        public String grpnam=null;
        public String ctyfun=null;
        public String cusnam=null;
        public String agtcod=null;     //     agtcod: this is asocod
        public String agtnam=null;
        public String whwtyp=null;     //     whwtyp
        public String corcod=null;     //     corcod
        public String ibpgrp=null;     //     ibpgrp
        public String ibpnam=null;
        public String sucmsg=null;
        //public String ibpnam=null;
        public String WorkBook=null;
        public String Authorised=null;
        public byte[] WHWFile=null;
        public Vector WHWData=null;
        public String fname=null;
        public int WHWexist=0;
        public Vector Err_WHWData=null;
        public Vector WHW_File_List=null;
        public Vector WHW_File_List_err=null;
        //     TTL WHW
        public String TTLPRVORD=null;
        public String TTLPRVWHW=null;
        public String TTLCURORD=null;
        public String TTLCURWHW=null;
         // Inquiry
        public String iq_usrcod=null;
        public String iq_lognam=null;
        public String iq_agtcod=null;     //     agtcod
        public String iq_agtnam=null;
        public String iq_ibpgrp=null;     //     ibpgrp
        public String iq_ibpnam=null;
        public String iq_ctyfun=null;
        public String iq_whwtyp=null;
        public String sDublicate="";  //dublicate string declaration
        public Connection conn=null;
            public WHWBean() {
    //     -----     Methods        -----     //
              public void iq_DataClear(){
                   this.iq_agtcod=null;
                   this.iq_agtnam=null;
                   this.iq_ibpgrp=null;
                   this.iq_ibpnam=null;
                   this.iq_ctyfun=null;
                   this.iq_whwtyp=null;
                   //System.out.println("this.iq_whwtyp: "+this.iq_whwtyp);
              public void DataClear(){
                   this.agtcod=null;
                   this.agtnam=null;
                   this.ibpgrp=null;
                   this.ibpnam=null;
                   this.ctyfun=null;
                   this.WHWFile=null;
                   this.WHWData=null;
                   this.fname=null;
                   this.WHWexist=0;
                  this.TTLPRVORD=null;
                  this.TTLPRVWHW=null;
                  this.TTLCURORD=null;
                  this.TTLCURWHW=null;
                  this.status=null;
                  this.sucmsg=null;
                  this.ErrFlg=null;
                  this.Err_WHWData=null;
              public void ClearAll(){
                   this.whwtyp=null;
                   this.agtcod=null;
                   this.agtnam=null;
                   this.ibpgrp=null;
                   this.ibpnam=null;
                   this.ctyfun=null;
                   this.WHWFile=null;
                   this.WHWData=null;
                   this.fname=null;
                   this.WHWexist=0;
                  this.TTLPRVORD=null;
                  this.TTLPRVWHW=null;
                  this.TTLCURORD=null;
                  this.TTLCURWHW=null;
                  this.status=null;
                  this.sucmsg=null;
                  this.ErrFlg=null;
                  this.Err_WHWData=null;
                  this.WHW_File_List=null;
                  this.WHW_File_List_err=null;
              public String getParam(String param, MultipartRequest mr){
                   if ( (param.length()>=0)&&(mr!=null) ){
                        String [] values = mr.getParameterValues( param.trim() );
                        String value = values[0];          
    //                    System.out.println(param+": "+value);     
                        return (value==null)? null:value;
                   } else {
                        return null;
              public Connection getConnection(){
                   Connection con = null;
                   try{
                             com.sql.query dbBean=new com.sql.query();
                             con=dbBean.getConnection("WHW");
                             con.setAutoCommit(false);
                   }catch(Exception e){
                             e.printStackTrace();
                   return con;
              public int Chk_WHW_Rignt( String[] User_Data ){
                   if ( (User_Data[3]!=null)&&(User_Data[3].equals("AGT")) ){
                        this.WHW_Right=1;
                        this.Staff_Right=0;
                        return 1;
                   } else if ( (User_Data[6]!=null)&&(User_Data[6].indexOf("W")>-1) ){
                        this.WHW_Right=1;
                        this.Staff_Right=1;
                        return 1;
                   } else if ( (User_Data[16]!=null)&&(User_Data[16].indexOf("D")>-1) ){
                        this.WHW_Right=1;
                        this.Staff_Right=1;
                        return 1;
                   } else {
                        this.WHW_Right=0;
                        this.Staff_Right=0;
                        return 0;
                    public int CheckExist(String lognam, String ibpgrp, String ctyfun, String agtcod){
                   int Result=-1;
                   Statement stmt = null;
                   ResultSet rs = null;
                   Connection con = null;
                   PreparedStatement pstmt = null;
                   String SQLstatement = null;
                   //StringBuffer option = new StringBuffer("");
                   try {
                        con=getConnection();
                        //String SQLstatement = "select dstfun from adm_dw1.saldmdst where dstkey=? ";
                        if ( (lognam!=null)&&(ibpgrp!=null)&&(ctyfun!=null) ){
                             SQLstatement ="SELECT count(b.crtlog) FROM adm_web.whwhddsk b "+
                                                 "WHERE b.lognam=? and b.ibpgrp=? and b.ctyfun=? and b.asocod=? and b.uplerr='N' and b.tsfusr is null";
    //                         System.out.println("CheckExist() - SQLstatement :\n"+SQLstatement);
                             pstmt = con.prepareStatement(SQLstatement);
                             pstmt.setString(1, lognam.trim());
                             pstmt.setString(2, ibpgrp.trim());
                             pstmt.setString(3, ctyfun.trim());
                             pstmt.setString(4, agtcod.trim());
                                rs = pstmt.executeQuery();
                             if (rs.next()) {
                                  Result = rs.getInt(1);
                        return Result;
                   } catch (Exception ex) {
                        System.out.println("CheckExist() ----- " + ex);
                        return -1;
                   } finally {
                        try {
                             if (rs != null) {
                                  rs.close();
                             if (stmt != null) {
                                  stmt.close();
                             if (pstmt != null) {
                                  pstmt.close();
                             if (con != null) {
                                  con.close();
                        } catch (SQLException ex) {
                             System.out.println("CheckExist() ----- " + ex);
              public String GetCusInfo(String usrcod){
                   Statement stmt = null;
                   ResultSet rs = null;
                   Connection con = null;
                   PreparedStatement pstmt = null;
                   String SQLstatement = null;
                   try {
                        con=getConnection();
                        //String SQLstatement = "select dstfun from adm_dw1.saldmdst where dstkey=? ";  
                        if ( (usrcod!=null)&&(usrcod.length()>0)){               
                             SQLstatement ="SELECT a.cusnam, a.grpnam, a.grpcod, b.ctyfun "+
                                  "from adm_dw1.saldmcus a, adm_dw1.saldmcty b where a.grpste=b.stecod and a.cuscod=?";
    //                    System.out.println("WebBean.GetCusInfo() - SQLstatement :\n"+SQLstatement);
                        pstmt = con.prepareStatement(SQLstatement);
                        pstmt.setString(1, usrcod.trim());
                           rs = pstmt.executeQuery();
                        if (rs.next()) {
                             this.cusnam=rs.getString(1);
                             this.grpnam=rs.getString(2);
                             this.ibpgrp=rs.getString(3);
                             this.ctyfun=rs.getString(4);
                             System.out.println("cusam:"+rs.getString(1)+" grpnam:"+rs.getString(2)+" ibpgrp:"+rs.getString(3)+" ctyfun:"+rs.getString(4));
                             return "T";
                        } else {
                             System.out.println("No customer information");
                             return "F";
                   } catch (Exception ex) {
                        System.out.println("WebBean.GetCusInfo() ----- " + ex);
                        return "F";
                   } finally {
                        try {
                             if (rs != null) {
                                  rs.close();
                             if (stmt != null) {
                                  stmt.close();
                             if (pstmt != null) {
                                  pstmt.close();
                             if (con != null) {
                                  con.close();
                        } catch (SQLException ex) {
                             System.out.println("WebBean.GetCusInfo() ----- " + ex);
                    public Vector getWHWData( int[] item, int[] prd, int[] mon, int[] n_item, int[] n_prd, int[] n_mon, byte[] bf ){
                   String Err=null;
                   int exit=-1;
                   int Complete=0;
                   int rows=0;
                   int columns=0;
                   String Sname="";
                   String version="";
                   Vector tb=new Vector();
                   String Valid="";
                   int r_diff= n_item[1]-item[1];
                   int r_whw=mon[1]-item[1];
                   int prow=0;
                   int p_item=0;
                   int p_prd=0;
                   int p_whw=0;
                   try{
                        //System.out.println("bf.length: "+bf.length);
                        ByteArrayInputStream bis= new ByteArrayInputStream( bf );
                        Workbook w = Workbook.getWorkbook( bis );
                        version=w.getVersion();
                        //System.out.println("whw.xls-sheets: "+w.getNumberOfSheets());
                        Sheet s= w.getSheet(0);
                        Sname=s.getName();
                        rows=s.getRows();
                        columns=s.getColumns();
                                  //  System.out.println("Inside get WHW");
                        System.out.println("Columns: "+s.getColumns()+" \tRows: "+s.getRows());
                        if (s.getRows()>12){
                             Cell[] CellA4=s.getRow(3);
                             String str_c4=CellA4[0].getContents();
                             if ( (str_c4.lastIndexOf(":")>-1)&&(str_c4.lastIndexOf("-")>-1) ){
                                  String str_whw_typ=str_c4.substring(0, str_c4.lastIndexOf(":") ).trim();
                                  //System.out.println( "WHW type:"+str_whw_typ );
                                  if ( str_whw_typ.equalsIgnoreCase("Associate Country") ){
                                       String str_whw=str_c4.substring(str_c4.lastIndexOf(":")+1 ).trim();
                                       //System.out.println( "WHW Country:"+str_whw );
                                       String str_asocod=str_whw.substring( 0, str_whw.indexOf("-") ).trim();
                                       //System.out.println( "asocod:"+str_asocod );
                                       String str_ctyfun=str_whw.substring( str_whw.indexOf("-")+1 ).trim();
                                       //System.out.println( "ctyfun:"+str_ctyfun );
                                       this.ctyfun=str_ctyfun;
                                       this.agtcod=(str_asocod.equals(""))?" ":str_asocod;
                                       this.whwtyp="Country";
                                  } else if ( str_whw_typ.equalsIgnoreCase("Customer")|| str_whw_typ.equalsIgnoreCase("IBP Group")) {
                                       String str_whw=str_c4.substring(str_c4.lastIndexOf(":")+1 ).trim();
                                       //System.out.println( "WHW IBP:"+str_whw );
                                       String str_ibpgrp=str_whw.substring( 0, str_whw.lastIndexOf("-") ).trim();
                                       //System.out.println( "ibpgrp:"+str_ibpgrp );
                                       this.ibpgrp=str_ibpgrp;
                                       this.whwtyp="Customer";
                                  } else {
                                       Valid=Valid+"Unknown customer or country";
                             } else {
                                  Valid=Valid+"Unknown upload type";
                             Cell[] hdcs=null;
                             NumberCell nfc=null;
                             hdcs=s.getRow(1);
                             if (hdcs[mon[0]+13].getType()==CellType.NUMBER_FORMULA){
                                  this.TTLPRVORD=hdcs[mon[0]+13].getContents();
                                  //System.out.println("TTLPRVORD - Celltype:"+hdcs[mon[0]+13].getType()+"\n hdcs["+(mon[0]+13)+"].getContents():"+hdcs[mon[0]+13].getContents());
                             } else {
                                  //System.out.println("Valid:"+hdcs[mon[0]+13].getType());
                                  Valid=Valid+"Error in TTLPRVORD";
                             hdcs=s.getRow(2);
                             if (hdcs[mon[0]+13].getType()==CellType.NUMBER_FORMULA){
                                  this.TTLPRVWHW=hdcs[mon[0]+13].getContents();
                                  //System.out.println("TTLPRVWHW - Celltype:"+hdcs[mon[0]+13].getType()+"\n hdcs["+(mon[0]+13)+"].getContents():"+hdcs[mon[0]+13].getContents());
                             } else {
                                  //System.out.println("Valid:"+hdcs[mon[0]+13].getType());
                                  Valid=Valid+", TTLPRVWHW";
                             hdcs=s.getRow(3);
                             if (hdcs[mon[0]+13].getType()==CellType.NUMBER_FORMULA){
                                  this.TTLCURORD=hdcs[mon[0]+13].getContents();
                                  //System.out.println("TTLCURORD - Celltype:"+hdcs[mon[0]+13].getType()+"\n hdcs["+(mon[0]+13)+"].getContents():"+hdcs[mon[0]+13].getContents());
                             } else {
                                  //System.out.println("Valid:"+hdcs[mon[0]+13].getType());
                                  Valid=Valid+", TTLCURORD";
                             hdcs=s.getRow(4);
                             if (hdcs[mon[0]+13].getType()==CellType.NUMBER_FORMULA){
                                  this.TTLCURWHW=hdcs[mon[0]+13].getContents();
                                  //System.out.println("TTLCURWHW - Celltype:"+hdcs[mon[0]+13].getType()+"\n hdcs["+(mon[0]+13)+"].getContents():"+hdcs[mon[0]+13].getContents());
                             } else {
                                  //System.out.println("Valid:"+hdcs[mon[0]+13].getType());
                                  Valid=Valid+", TTLCURWHW";
                        if (Valid.length()>0) {
                             Err=Valid;
                        if ((s.getRows()>12)&&(Valid.equals(""))){
                             //exit=-1;
                             while( true ){
                                  String[] r = new String[15];
                                  if ( exit==-1 ) {
                                       //prow=fr_item;
                                       //System.out.println("Exit:-1, prow:7");
                                       prow=item[1];
                                       exit=0;
                                  //     TEXT -> CellType.EMPTY
                                                    //First row
                                  Cell[] cs=s.getRow( prow );
                                  //System.out.println( "before: cs[2]: "+ cs[2].getContents()+" cs[3]: "+ ((cs[3].getContents()=="")?"Null":cs[3].getContents()) );
                                  if (  (cs[item[0]].getContents()!="")&&(cs[item[0]].getType()!=CellType.EMPTY) ){
                                       Cell[] cs1=s.getRow( prow+r_whw );
                                       r[0]=cs[item[0]].getContents();
                                       r[1]=(cs[prd[0]].getType()==CellType.EMPTY)?null:cs[prd[0]].getContents();
                                       //System.out.println( "before: cs1[mon[0]] Type: "+ cs1[mon[0]].getType() );
                                       if ( (cs1[mon[0]-2].getContents()).equals("Cur. whw") ){
                                            //System.out.println("Getting the WHW data!");
                                       //searching for product code     
                                            r[2]=(cs1[mon[0]].getType()==CellType.EMPTY)?"0":cs1[mon[0]].getContents();
                                            r[3]=(cs1[mon[0]+1].getType()==CellType.EMPTY)?"0":cs1[mon[0]+1].getContents();
                                            r[4]=(cs1[mon[0]+2].getType()==CellType.EMPTY)?"0":cs1[mon[0]+2].getContents();
                                            r[5]=(cs1[mon[0]+3].getType()==CellType.EMPTY)?"0":cs1[mon[0]+3].getContents();
                                            r[6]=(cs1[mon[0]+4].getType()==CellType.EMPTY)?"0":cs1[mon[0]+4].getContents();
                                            r[7]=(cs1[mon[0]+5].getType()==CellType.EMPTY)?"0":cs1[mon[0]+5].getContents();
                                            r[8]=(cs1[mon[0]+6].getType()==CellType.EMPTY)?"0":cs1[mon[0]+6].getContents();
                                            r[9]=(cs1[mon[0]+7].getType()==CellType.EMPTY)?"0":cs1[mon[0]+7].getContents();
                                            r[10]=(cs1[mon[0]+8].getType()==CellType.EMPTY)?"0":cs1[mon[0]+8].getContents();
                                            r[11]=(cs1[mon[0]+9].getType()==CellType.EMPTY)?"0":cs1[mon[0]+9].getContents();
                                            r[12]=(cs1[mon[0]+10].getType()==CellType.EMPTY)?"0":cs1[mon[0]+10].getContents();
                                            r[13]=(cs1[mon[0]+11].getType()==CellType.EMPTY)?"0":cs1[mon[0]+11].getContents();
                                            r[14]=(cs1[mon[0]+12].getType()==CellType.EMPTY)?"0":cs1[mon[0]+12].getContents();
                                       } else {
                                            Err="WHW data of "+r[0]+" - "+r[1]+" was not found on row: "+(prow+r_whw+1)+" !" ;
                                       //System.out.println("r[0]: "+ r[0]+" r[1]: "+r[1]+" r[2]: "+r[2]);
                                       //System.out.println("prow-> "+prow+"; Rows-> "+rows);
                                  } else {
                                       Err="Item number not found on row: "+(prow+1)+" !";
                                  if ( Err==null ){
                                            //     valid data was added into the vector
                                       if ( (r[0]!=null)&&(!r[14].equals("0")) ){
                                            tb.addElement(r);
    public static void main(String args[]){                                                       
                                      hashtable hashtable[] = new hashtable();
                                                            tb.addElement(r);
                                                                   if (hashtable.get(p_item+p_prd)==null) {
                                                                           Enumeration e = hashtable1.keys();
                                                                           while( e. hasMoreElements() ){
                                                                            System.out.println( e.nextElement() );
                                                                   } else {
                                                            System.out.println(r[0]);
                                      hashtable hashtable[] = new hashtable();
                                                            tb.addElement(r);
                                                                   if (hashtable.get(p_item+p_prd)==null) {
                                                                           Enumeration e = hashtable1.keys();
                                                                           while( e. hasMoreElements() ){
                                                                            System.out.println( e.nextElement() );
                                                                   } else {
                                                            System.out.println(r[0]);
                                       //System.out.println("r add into tb: "+tb.size());
                                       prow=prow+r_diff;
                                       Cell[] cs3=s.getRow( prow+1 ); {//if the program cannot find item number then it would go to the next line down
                                       System.out.println("cs3 "+(prow+1));
                                                            System.out.println(cs3.length); // checking the size of the cs3 then go through the reach line and see the dump of type
                                                           // for(int i=0;i<cs3.length;i++){
                                                              //  System.out.println("cs3"+i+" "+cs3);
    // if (cs3[20].getContents().equals("TOTAL :") ){ //orginal code
                                       if (cs3.length>=21 && cs3[20].getContents().equals("TOTAL :")){  //edited code
    //System.out.println("cs3[20].getContents()"+cs3[20].getContents()+"*");
    //System.out.println("[20]!=0?"+cs3[20].getContents()!="0");
    // if (cs3[20].getType()=CellType.EMPTY || cs3[20].getContents().equals("Total: ")) { //edited by Antony                                              
    System.out.println("Complete sucessfully!- Total");
                                            Complete=1;
                                            break;
                                       } else if ( prow>=(rows-2) ){
                                            System.out.println("Complete sucessfully!");
                                            //this.status="Complete sucessfully!";
                                            Complete=1;
                                            break;                         
                                       } else {
                                            //System.out.println("prow-> "+prow+"; Rows-> "+rows); //another test in seeing it moving onto the next line
                                            Cell[] cs2=s.getRow( prow ); //this will get the row from the excel sheet
    System.out.println("Row number: "+prow);
    System.out.println("rows: "+rows);
                                            //System.out.println("cs2[4]-> "+cs2[4].getContents());
                                            if ( (cs2[item[0]].getContents()=="")||(cs2[item[0]].getType()==CellType.EMPTY) ) {// original code     
                                                 //System.out.println("In first empty row!");
                                                 cs2=s.getRow( prow+1 ); //check next product code and break due to error
                                                 //System.out.println("added 1");
    //At this point the programs deals with the next row
    if ( cs2[item[0]].getContents()=="" || cs2[item[0]].getType()==CellType.EMPTY) {     
    Err="There is nothing on next row:"+(prow+1+1)+" !";
    System.out.println("break on error! ->"+ Err);
                                                      break;
                                                 } else {
                                                      prow=prow+1;
    //System.out.println("prow+1-> "+prow+"; rows-> "+rows);
    //check if the program would jump to the next line if it cant find the item code from the excel.
                                            } else if
    //( (cs2[0].getType()==CellType.EMPTY)&&(cs2[4].getType()==CellType.EMPTY) ){ //original code
    // Referring to the description and the A column in excel, Linked to Item Code
    ( (cs2[0].getType()==CellType.EMPTY)&&(cs2[4].getType()==CellType.EMPTY)&&(cs2[2].getType()==CellType.EMPTY) ){
                                                 //System.out.println("Missing Description!"); //changed to missing description because it is not the last row.
    //System.out.println("Last Row!"); //edited by Antony
                                                 cs2=s.getRow( prow+1 );
    //if (cs2[item[18]].getContents()=="Total";)) //orignal code
    //change to
    if ( (cs2[22].getContents()=="TOTAL :") ){
    //Previous error conjured was array index out of bounds exception edited by Antony
                                                      Err="";
                                                      System.out.println("WHW Complete!");
                                                      break;
                             } else {
                                       System.out.println("break on error! ->"+ Err);
                                       break;
                        w.close();
                        //fis.close();
                        bis.close();
                        //System.out.println("Err: "+Err);
                        this.status=Err;
                        if ( Complete==1 ) {
                                  System.out.println("tb in getWHWData(): "+tb.size());
                                  return tb;
                        } else {
                             //System.out.println("getWHWData() get data fail!");
                             return null;
                   } catch (IOException e){
                   this.status="File is loaded in error.";
                   System.out.println(e.toString());
                   //e.printStackTrace();
                   //err=1;
                   return null;
                   } catch (BiffException t){
                        System.out.println(t.toString());
                        t.printStackTrace();
                        this.status="Version may be not supported or file may be corrupted.";
                        try{
                             Workbook w = Workbook.getWorkbook( new java.io.File("D:\\excel\\Empty.xls"));
                             w.close();
         //                    err=2;
                             System.out.println("Excel file is being loaded in error!");
                        } catch (IOException a){
                        System.out.println(a.toString());
                        } catch (BiffException b){
                             System.out.println(b.toString());
                             b.printStackTrace();
                        return null;
    public String WHW_to_DB( Connection conn, Vector itm_data, String lognam, String ibp, String cty, String Now, String asocod )throws SQLException{
                   ResultSet rs = null;
                   PreparedStatement pstmt = null;
                   Statement stmt = null;
                   String SQLstatement=null;
                   String[] Cursor=null;
                   try{
                        conn=getConnection();
                        conn.setAutoCommit(false);
                        //SQLstatement ="INSERT INTO adm_web.whwdtdsk values ( ?, ?, ?, to_date( ?, 'dd-mm-yyyy HH24:MI:SS'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
                        SQLstatement ="INSERT INTO adm_web.whwdtdsk "+
                                       " ( lognam, ibpgrp, ctyfun, crtlog, itmcod, prdcod, pjtd01, pjtd02, pjtd03, pjtd04, pjtd05, pjtd06, pjtd07, pjtd08, pjtd09, pjtd10, pjtd11, pjtd12, dirqty, asocod) "+
                                       "values ( ?, ?, ?, to_date( ?, 'dd-mm-yyyy HH24:MI:SS'), ?, ?, to_number(?,'9,999,999'), to_number(?,'9,999,999'), to_number(?,'9,999,999'), to_number(?,'9,999,999'), to_number(?,'9,999,999'), to_number(?,'9,999,999'), to_number(?,'9,999,999'), to_number(?,'9,999,999'), to_number(?,'9,999,999'), to_number(?,'9,999,999'), to_number(?,'9,999,999'), to_number(?,'9,999,999'), to_number(?,'999,999,999'), ? )";
                        pstmt = conn.prepareStatement(SQLstatement);
                        for (int n=0; n<itm_data.size(); ++n){
                             Cursor=(String[])itm_data.elementAt(n);
    System.out.println( "Lognam: "+lognam.trim()+" itmcod: "+Cursor[0]+" prdcod:"+Cursor[1]+" listed!" );
    // System.out.println( "Lognam: "+lognam.trim()+" itmcod: "+Cursor[0]+" prdcod:"+Cursor[1]+" in error!" );
                             //pstmt = conn.prepareStatement(SQLstatement);
    System.out.println("********************************************Start");
                             pstmt.setString( 1, lognam.trim() );
    System.out.println("1 "+lognam.trim()); //print login name
                             pstmt.setString( 2, ibp.trim() );
    System.out.println("2 "+ibp.trim()); // print ibp
                             pstmt.setString( 3, cty.trim() );
    System.out.println("3 "+cty.trim()); //print city name
                             pstmt.setString( 4, Now.trim() );
    System.out.println("4 "+Now.trim()); //print out now //what is now???
                             pstmt.setString( 5, Cursor[0].trim() );
    System.out.println("5 " +Cursor[0].trim());
    pstmt.setString( 6, (Cursor[1]==null)?" ":Cursor[1].trim() );
    System.out.println("6" +(Cursor[1]==null?" ":Cursor[1].trim()));
    pstmt.setString( 7, Cursor[2].trim() );
    System.out.println("7 " +Cursor[2].trim());
    pstmt.setString( 8, Cursor[3].trim() );
    System.out.println("8 "+Cursor[3].trim());;
    pstmt.setString( 9, Cursor[4].trim() );
    System.out.println("9 "+Cursor[4].trim());
                             pstmt.setString( 10, Cursor[5].trim() );
    System.out.println("10 "+Cursor[5].trim());
    pstmt.setString( 11, Cursor[6].trim() );
    System.out.println("11 "+Cursor[6].trim());
    pstmt.setString( 12, Cursor[7].trim() );
    System.out.println("12 "+Cursor[7].trim());
    pstmt.setString( 13, Cursor[8].trim() );
    System.out.println("13 "+Cursor[8].trim());
    pstmt.setString( 14, Cursor[9].trim() );
    System.out.println("14 "+Cursor[9].trim());
    pstmt.setString( 15, Cursor[10].trim() );
    System.out.println("15 "+Cursor[10].trim());
    pstmt.setString( 16, Cursor[11].trim() );
    System.out.println("16 "+Cursor[11].trim());
    pstmt.setString( 17, Cursor[12].trim() );
    System.out.println("17 "+Cursor[12].trim());
    pstmt.setString( 18, Cursor[13].trim() );
    System.out.println("18 "+Cursor[13].trim());
    pstmt.setString( 19, Cursor[14].trim() );
    System.out.println("19 "+Cursor[14].trim());
    pstmt.setString( 20, asocod ); //duplicate error
    System.out.println("20 "+asocod.trim());
    pstmt.executeUpdate();
    System.out.println("********************************************END");
    //System.out.println("SQLstatement "+SQLstatement);
                        //conn.commit();
    return "T";
                   /*} catch (SQLException se) {
                        System.out.println( "Lognam: "+lognam.trim()+" itmcod: "+Cursor[0]+" prdcod:"+Cursor[1]+" in error!" );
                        System.out.println("WHW_to_DB() ----- " + se);
                        return "F";
                   }catch(Exception e){
                        System.out.println("WHW_to_DB() ----- " + e);
                        //return e.toString();
                        return "F";*/
                   } finally {
                        try {
                             if (rs != null) {
                                  rs.close();
                             if (stmt != null) {
                                  stmt.close();
                             if (pstmt != null) {
                                  pstmt.close();
                        } catch (SQLException ex) {
                             System.out.println("WHW_to_DB() ---

  • 9.2.0 OCCI's setString Won't Work, Need Help w Thks

    Start exploring occi.h (oracle version 9.2.0) but hit a problem w no clue to solve it.
    #include <iostream>
    #include <occi.h>
    using namespace oracle::occi;
    using namespace std;
    int main()
    // declare Environment, Connection, ResultSet, Statement
    env=Environment::createEnvironment(Environment::DEFAULT);
    con=env->createConnection("myname", "mypws", "myConString");
    stmt=con->createStatement("select * from aTable where aFld=:1 and bFld=:2");
    stmt->setInt(1, 10);
    stmt->setString(2, "myValue");
    rs=stmt->executeQuery();
    rs->next();
    // cout result, all fields empty, seems a result not found
    stmt=con->createStatement("select * from aTable where aFld=10 and bFld='myValue'");
    rs=stmt->executeQuery();
    rs->next();
    // cout result, got the record and print expected result.
    // close connection on env, rs, stmt, con
    the diff. between 1st & 2nd SQL stmt is one is parameterize and the other is not. If in 1st SQL stmt, I hard code :2 to 'myValue' and then execute setInt() only, it works as well. So it is the 'setString()' function that won't work.
    Any idea?
    You help is really appreciated.
    Thanks
    Message was edited by: chris
    user459175

    Hi Nikeda
    The bFld is in char(10).
    You are correct, so when I change the sql stmt to "select * from aTable where aFld=:1 and trim(bFld)=:2", it works. Or when I change "myValue" to "myValue<+ 3 space", it works as well.
    Thanks

  • When placing a PDF created with Distiller, I only get Crop and Media as import options -- I need it to crop to the Trim! PLEASE HELP!

    I'm having a MAJOR problem placing PDF files in InDesign CS4...
    When I try to place a PDF that has been created in Distiller, the ONLY import options I can choose are CROP and MEDIA. I need it to crop to the TRIM, but that option is grayed out. The PDFs I'm trying to place were created in-house, and converted from Post Script files to PDFs using Distiller. We use PDF/X-1a equivalent settings when creating our PDFs.
    If I export the file as a PDF and then try to place it into a CS4 file, I am able to select Trim as an option.
    ALSO, if I open the Distiller PDF in Acrobat and then save it (without changing anything), I am able to select Trim as an option. A workaround I have found is to open all of the PDF files in Acrobat, save them to my desktop, and then save over the ones I need to place. Here's the problem with that: I work for a publishing company, and need to place hundreds of ads for each issue of our publications, and it adds a lot of time if I have to go and re-save everything just to be able to place all the ads. 
    Does anyone know how to fix this problem? I need to get this figured out so we can use CS4 for all of our publications again. -- We've gone back to using CS3 until I can get this figured out...
    - Valerie

    Steve,
    Thanks for the reply, but my PDFs all have trim boxes on them. If I try to place the same PDF in InDesign CS3, it gives me Trim as an option. Also, if I open the PDF and save a copy to my desktop, I am able to select Trim as an option when placing the PDF, and I didn't change anything about it.
    I've been trying to see if it's something with the Print Preset settings I'm using, but I can't find anything that seems like it would affect how InDesign would read the Trim area of the PDF.
    I've attached 2 PDF files. One that was created with Distiller, and one that was exported from InDesign CS4. The Distiller one doesn't show Trim as an option in CS4, but the exported one does.... but they started out as the same ad.  Ugh!  Help me please!
    - Valerie

  • Can't hear audio in trim mode.

    When I'm in trim mode and I play, in order to move the cut, I can't hear any audio.  It has nothing to do with scrubbing on/of because pressing shift+s has no effect.  It's also not working when I'm holding down "K" and pressing "L" simultaneously.
    DrL

    works for me.  Have you looked in the view menu to make sure audio scrubbing is checked?  It's possible you've reset the keyboard shortcut or your keyboard has somehow or other gotten corrupted.  You might try deleting your fcp preferences.  Use this:
    http://www.digitalrebellion.com/prefman/

  • The "write key" configurat​ion file vi use of "trim string" prior to writing the data can modify any string data written.

    I tried to use the config VIs to record some front-panel settings for later restoration, one of which could be a single space character (part of a string parsing system).
    I soon discovered that whenever I tried to save that single-space value to an INI file, only a null string was saved.
    After doing some digging I discovered that buried in the Write Key vi is a worker vi called Config Data Modify that uses Trim String on the string data before it is written to the file and that's what was eating my string character. I don't know whether this is a bug or a feature but there are at least three ways to fix it.
    1) Assuming you want to leave the library VIs alone, you can pre-process any stings sent to "write key" to replace all spaces with "\20" and then post-process all strings read using "read key" to replace all instances of \20 with spaces.
      and if you don't mind modifying the library VIs, either to save/use under a different name or to stick back into the library in a modified state (caution - can cause problems when you move code to another machine with an un-modified library) then...
    2) You can yank the trim-string out of the Config Data Modify vi and hope that it does not have any undesirable side effects with regards to the other routines that use Config Data Modify (so far I have not found any in my limited testing)
    or
    3)  You can modify the string pre-processing vi, Remove Unprintable Chars, to add the space character to the list of characters that get swapped out automatically.
    Note that both option #1 (as suggested above) and option #3 will produce an INI file data entry that looks like    key="\20Hello\20World\20"   while option #2 produces an entry that looks like   key=" Hello World "
    The attached PDF contains screenshots of all this.
    Attachments:
    Binder1.pdf ‏2507 KB

    Hi Warren,
    there's a 4th option:
    Simply set the "write raw string" input of the write key function to TRUE
    This option only appears when a string is wired to that function!
    Just re-checked:
    I think it's a limitation of the config file format. It's text based and (leading) spaces in the value are "overseen" as whitespaces. So your next option would be to use quotes around your string with spaces...
    Message Edited by GerdW on 05-02-2009 08:32 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Voice memos trim iPhone 5

    Hello!.. I need to know how to trim in voice memos

    Tap the Voice Memo, Tap Edit at the bottom, then tap the name.  I have pointed the name you want to tap in the screenshot below. In this example, the name is "New Recording"

  • Need help with trim and null function

    Hi all,
    I need help with a query. I use the trim function to get the first three characters of a string. How do I write my query so if a null value occurs in combination with my trim to say 'Null' in my results?
    Thanks

    Hi,
    Thanks for the reply. What am I doing wrong?
    SELECT trim(SUBSTR(AL1.user_data_text,1,3)),NVL
    (AL1.user_data_text,'XX')
    FROM Table
    I want the XX to appear in the same column as the
    trim.The main thing you're doing wrong is not formatting your code. The solution may become obvious if you do.
    What you're saying is:
    SELECT  trim ( SUBSTR (AL1.user_data_text, 1, 3))
    ,       NVL ( AL1.user_data_text, 'XX' )
    FROM    Tablewhich makes it clear that you're SELECTing two columns, when you only want to have one.
    If you want that column to be exactly like the first column you're currently SELECTing, except that when that column is NULL you want it to be 'XX', then you have to apply NVL to that column, like this:
    SELECT  NVL ( trim ( SUBSTR (AL1.user_data_text, 1, 3))
                , 'XX'
    FROM    Table

Maybe you are looking for

  • Numbers (and pages and keynote) doesn't open

    Hey people. once more I have an issue with my mac retina iOS Lion 10.8.2. I just downloaded Numbers 2.3 on my mac but, when I try to open it, just doesn't show anything, after that i need to force close. This is te report. I hope someone can help me,

  • Apple TV purchase won't sync and disappeared

    I purchased a movie two nights ago on my gen 1 Apple TV, watched it, and it would not sync with iTunes account and now it no longer appears on the Apple TV?  Anyone else have this problem and a fix? Apple TV

  • How to halt the execution of JSP page..

    Hello all, I want to halt the execution of JSP page suppose for 10 seconds can anyone tell me how to do this Thanks Uttam

  • 3 flashes and no bootup

    Randomly my Macbook Pro will flash at me 3 times over and over again. When i turn it off and turn it back on, it will boot properly. It does this all the time when i first start it up. What is causing this?

  • Auto mounting different network volumes

    I have a MacBook Pro. I use it at the office and at home. When I am in the office, I have one set of network volumes that I mount. At home, I have another (e.g. Airdisk, iMac HD, etc.) I would like to figure out a way to have the right drives mounted