Inserting into a record into a database

When i cal the following method (only part of the method) the method executes fine with any exceptions or errors however the company which is meant to be added to the database does not get added. Does anybody know what the problem could be?
else
int uniqueIDPortfolio = Variables.getSelectedPortfolio ();
     System.out.println(uniqueIDPortfolio);
     queryString = "INSERT INTO CompanyDetails VALUES(";
     queryString += uniqueIDPortfolio + ",";
     queryString += "'" + symbol + "',";
     queryString += "'" + value00 + "',";
     queryString += "'" + value01 + "',";
     queryString += "'" + value02 + "',";
     queryString += "'" + value03 + "',";
     queryString += "'" + value04 + "',";
     queryString += "'" + value06 + "',";
     queryString += "'" + value07 + "',";
     queryString += "'" + value08 + "',";
     queryString += "'" + shares + "',"; // no of shares
     queryString += "'" + price + "',"; // total price paid
     queryString += "'" + value09 + "',";
     queryString += "'" + value10 + "',";
     queryString += "'" + value11 + "',";
     queryString += "'" + value12 + "',";
     queryString += "'" + value13 + "',";
     queryString += "'" + value14 + "',";
     queryString += "'" + value15 + "',";
     queryString += "'" + value16 + "',";
     queryString += "'" + value17 + "',";
     queryString += "'" + value18 + "',";
     queryString += "'" + value19 + "',";
     queryString += "'" + value20 + "',";
     queryString += "0,";
     queryString += "0,";
     queryString += "False,";
     queryString += "4";
     queryString += ")";
System.out.println(queryString);
     // insert the company into the database. Data needs to be added to the CompanyDetails table
     myStatement.executeUpdate(queryString);
Thank You for your assistance

I have changed it so that it is no longer a method.what does this have to with anything?
I now get a SQL exception. ah-ha!
could you perhaps copy and paste the exception here so that we might be enlightened as to what exactly is going wrong. a stack trace might be good.
Can i use MS Access to check
if the sql statement is correct? If so how would i do
this?yes. when you print out the query to the console (the command or DOS window) copy and paste it into the access query tool.
to open up the access SQL query thing do the following.
open the database in access.
go to the queries tab.
select new.
select design view.
close the select table prompt thingy.
now go to the top menu (File, Edit, etc) and select view.
select SQL view.
paste the query in there.
execute the query by clicking the exclamation point.
voila.

Similar Messages

  • Reading content to insert into a database for file content searches

    I have a new challenge that has been brought to me.
    There is and existing application that has files being inserted into the database and the customer is having great difficulty in being able to have a search capability against those files. I was thinking that I could do a secondary lookup before the file is actually uploaded and there would be use of the cffile to read the file then insert that data from the read and insert that data into a column of that database the equiled that record. The most important part of this is that the file's content is read from cffile and inserted into a column that actually get's that data into the RBDMS system that will allow for a full text search that would point to that system.
    Any other ideas of how to insert document content into a data record other than using the cffile tag would be most appreciated.
    Thanks in advance.
    Gene

    Most, if not all, database management systems have their own features to read text data from files.  You may prefer that functionality over piping the data through ColdFusion and the database drivers.
    <cffile...> can "read" .doc and .pdf file as in it can read the file from the file system as the binary data they are, but that does not extract the text from the content.  You can do some stuff with CFML to read the text in a pdf file with the <cfpdf...> and related tags and functions.  I'm not aware of similar CFML features that work with doc files, but I know of Java tools that do such as POI.  These are usually fairly straight forward to tap into with ColdFusion.

  • Get the data  from excel and insert into the database

    I want to read the data from excel file, get the data from excel and insert into the database.

    You can use the Apache POI HSSF API to read data from Excel files and you can use the Sun JDBC API to insert data in database.
    This has nothing to do with JSP/JSTL.

  • Insert into SQL database

    Hi,
    I am using xMII v 11.5..I need to insert into SQL database.
    In BLS
    Step 1:I am using an SQL Query1 it fetches data
    Step 2:  I am using 4 calculation Action block to calculate the values
    Step 3: I am inserting the Calculated values using an SQL Query2
    In the links when i evaluate its showing the value but when i check in the SQL Database it has inserted zeros...
    I found that the first Query is not returning anything if i have set the Date condition in where clause...
    Regards
    Sweety
    Edited by: sweety_VA on Apr 25, 2011 7:32 AM

    Hi Sweety,
    Can you provide some more information? 
    The script for each of your queries.  (looking especially at how you are using single quotes around the Param properties for different data types)
    Are you using an Command SQL Query for the insert?
    Why are you using the Calculation action block instead of using the Expression Editor for the calculation?
    Regards,
    Mike

  • How to execute a Java method when row inserted into a database table?

    I have the need to fire off a java method when a row is inserted into a database table. I am unfortunately working with MySQL which just recently supported triggers but these new triggers can not execute a Java application on any event.
    What I am looking for is an event driven approach such that when a row is inserted into a specific table I can fire off a java method (sitting in a tomcat container) that will take the contents and send it to a web service.
    It has been mentioned that JMS may have the ability to poll and monitor a database table. Just wondering if anyone could point me in the right direction.
    thanks
    JavaTek

    A service handler might be the right way to run some code at the end of a service call (another way would be to make use of filters).
    First, make sure your static table is merged with ServiceHandlers.
    Secondary, change your custom method name into one that is not already in the service definition of COLLECTION_COPY_LOT (preferably a unique method name like collectionCopyLotLastAction that describes its purpose) and remove the following line from your code:
    m_service.doCodeEx("",this);Now create a service definition for COLLECTION_COPY_LOT in your custom component based on the original COLLECTION_COPY_LOT (copy paste from the original service definition) and add you own method collectionCopyLotLastAction as the last step in the service. Play with the load order to make sure CS is using your service definition of COLLECTION_COPY_LOT instead of the original.
    regards,
    Fabian

  • Insert into Oracle Database using C#

    Hi Everyone,
    I am trying to take data from text box and list box and then insert them to Oracle database:
    Text box data:
    Oracle = EMPLOYEE_NAME
    C# = tbEmployeeName
    List box data:
    Oracle = EMPLOYEE_GENDER
    C# = lbEmployeeGender
    Here is my code in C#, can you guys help me with insert statement:
    string oradb = "Data Source= oraDB;User Id=sm;Password=mypassword;";
    OracleConnection conn = new OracleConnection(oradb);
    conn.Open();
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = conn;
    cmd.CommandText = "Insert into USER.EMPLOYEE VALUES (tbEmployeeName.Text, lbEmployeeGender.Text)";
    int rowsUpdated = cmd.ExecuteNonQuery();
    if (rowsUpdated == 0)
    MessageBox.Show("Record not inserted");
    else
    MessageBox.Show("Success!");
    conn.Dispose();
    Thanks!

    989630 wrote:
    Hi Everyone,
    I am trying to take data from text box and list box and then insert them to Oracle database:
    Text box data:
    Oracle = EMPLOYEE_NAME
    C# = tbEmployeeName
    List box data:
    Oracle = EMPLOYEE_GENDER
    C# = lbEmployeeGender
    Here is my code in C#, can you guys help me with insert statement:
    string oradb = "Data Source= oraDB;User Id=sm;Password=mypassword;";
    OracleConnection conn = new OracleConnection(oradb);
    conn.Open();
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = conn;
    cmd.CommandText = "Insert into USER.EMPLOYEE VALUES (tbEmployeeName.Text, lbEmployeeGender.Text)";
    int rowsUpdated = cmd.ExecuteNonQuery();
    if (rowsUpdated == 0)
    MessageBox.Show("Record not inserted");
    else
    MessageBox.Show("Success!");
    conn.Dispose();
    Thanks!Hi,
    You'll want to read up on using parameters (also known as bind variables) - these are critical for scalability in an OLTP-type system and helping guard against SQL Injection attacks. There's many sources out there, but here's a link to the Parameter Binding section in the ODP.NET Developer's Guide which is probably a good thing to become familiar with:
    http://docs.oracle.com/cd/E11882_01/win.112/e23174/featOraCommand.htm#i1007242
    Here's your sample using bind variables:
    string oradb = "Data Source= oraDB;User Id=sm;Password=mypassword;";
    OracleConnection conn = new OracleConnection(oradb);
    conn.Open();
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = conn;
    // Perform insert using parameters (bind variables)
    cmd.CommandText = "Insert into USER.EMPLOYEE VALUES (:1, :2)";
    // Here's one way to use parameters aka bind variables:
    // Create parameters to hold values from front-end
    cmd.Parameters.Add(new OracleParameter("1",
                                           OracleDbType.Varchar2,
                                           tbEmployeeName.Text,
                                           ParameterDirection.Input));
    cmd.Parameters.Add(new OracleParameter("2",
                                           OracleDbType.Varchar2,
                                           lbEmployeeGender.Text,
                                           ParameterDirection.Input));
    int rowsUpdated = cmd.ExecuteNonQuery();
    if (rowsUpdated == 0)
      MessageBox.Show("Record not inserted");
    else
      MessageBox.Show("Success!");
    conn.Dispose();
    // don't forget to perform any clean-up as necessaryNote that I've just typed this into a text editor and not verified, so please excuse any typos you may find.
    Also, I've allowed the default of OracleCommand.BindByName=false as I prefer that, though others certainly prefer setting it to "true". See the docs for what this means if you are not sure.
    Regards,
    Mark

  • Insert into different database - same server

    What do I need to do to insert values into a table in a database on the same server?
    I have databases A and B. I have a procedure in Database B that needs to insert a record into a table in Database A. I tried qualifying:
    Insert into DataBaseA.SchemaA.tableA (fields..) Values (values...); but that didn't work. I saw something on creating a link but I didn't quite understand it and all of the posts I have read haven't really given a clear syntax usage.
    Can anyone help? I also don't know the table to insert into until the procedure is run so I can't create anything "static".
    Thanks,
    Greg

    Hi Greg,
    You have to create a database link. Go through the following link for details:
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_56a.htm#SQLRF01205
    Please let me know if you still have any concern.
    Regards
    Ghulam

  • Inserting into MsAccess Database

    Hi,
    I am having problem with inserting a row into the MsAccess Database. I am getting error like
    "SQLException: Occurred while performing Database Operations ---> method Main() java.sql.SQLException
    : [Microsoft][ODBC Microsoft Access 97 Driver] Syntax error in INSERT INTO statement.[Microsoft][ODB
    C Microsoft Access 97 Driver] Syntax error in INSERT INTO statement".
    My code is as under:
    please help me out.
    Smitha
    ==========================================
    package dao;
    import utils.GeneralFailureException;
    import dbConnection.dbConnection;
    import java.util.*;
    import java.sql.*;
    public class GeneralExpenses {
    dbConnection dbCon = new dbConnection();
    public GeneralExpenses() {
         super();
    public static java.sql.Timestamp getTstamp() {
    java.util.Date date = (Calendar.getInstance()).getTime();
    java.sql.Timestamp tStamp = new java.sql.Timestamp(date.getTime());
    System.out.println("The Time Stamp : " + tStamp);
    return tStamp;
    public void insertExpenseTable(String sExphead, double dAmount, String sMode)
         throws GeneralFailureException, SQLException, ClassNotFoundException {
         String inssql = "INSERT INTO EXPENSES(tnum, date , " + sExphead + ", " + sMode + ") VALUES(?,?,?,?)";
         Connection conn = null;
         PreparedStatement pstmt = null;
         try {
              conn = dbCon.getConnection();
              pstmt = conn.prepareStatement(inssql);
              pstmt.setInt(1, 100);
              pstmt.setTimestamp(2, getTstamp());
              pstmt.setDouble(3, dAmount);
              pstmt.setString(4, sMode);
              pstmt.executeUpdate();
         } finally {
              dbCon.closeAll(pstmt, conn);
    public static void main(String[] args) {
         try {
    GeneralExpenses ge = new GeneralExpenses();
         ge.insertExpenseTable("xxxxxxx", 250.35, "yyyyyyyy");
         System.out.println("worked");
         } catch(ClassNotFoundException sqlex) {
         System.err.print("SQLException: Occurred while performing Database Operations ---> method Main() " + sqlex);
         System.err.println(sqlex.getMessage());
         catch(SQLException sqlex) {
         System.err.print("SQLException: Occurred while performing Database Operations ---> method Main() " + sqlex);
         System.err.println(sqlex.getMessage());
    } catch(GeneralFailureException e) {
         System.err.print("GeneralFailureException: Occurred while Establishing Connection ---> method getConnection() " + e);
         System.err.println(e.getMessage());
    } catch(Exception e) {
         System.err.print("GeneralFailureException: Occurred while Establishing Connection ---> method getConnection() " + e);
         System.err.println(e.getMessage());

    I'm so happy to finally found the answer of my problem with that message Kurt.
    Thank you very much... !
    I will now remember that date cannot be the name of a field when using jdbc-odbc. I called my field TransDate and it is now working perfectly!

  • Any way to insert into a database clob other than streaming chars ?

    I have a jsp with a textarea object which I am inserting into an Oracle clob.
    I am using the thin driver.
    I have a problem in that if it is quite large (say over 2K) it falls over with "connection reset by peer" I think this may be because you aren't supposed to use this method with the thin driver, but I don't want to use OCI.
    So is there any other way to insert my text into the database without having to explicitly select the row first for update as this is essentially a new insert so doing it like this I would have to first of all insert the other columns then reselect the row for update of the clob.
    Thanks.

    Most, if not all, database management systems have their own features to read text data from files.  You may prefer that functionality over piping the data through ColdFusion and the database drivers.
    <cffile...> can "read" .doc and .pdf file as in it can read the file from the file system as the binary data they are, but that does not extract the text from the content.  You can do some stuff with CFML to read the text in a pdf file with the <cfpdf...> and related tags and functions.  I'm not aware of similar CFML features that work with doc files, but I know of Java tools that do such as POI.  These are usually fairly straight forward to tap into with ColdFusion.

  • Problem inserting into access database.

    I am using the following code to create a table and insert values into an access database. Problem is that it only inserts the first 3 values no matter what order they are in. Any help is appreciated, and thanks in advance.
          stmt.executeUpdate("CREATE TABLE HardDrive (HardDriveID VARCHAR(10),"           + " HardDriveName VARCHAR(30), HardDriveSize VARCHAR(6), Price CURRENCY)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('WD3000HLFS','Western Digital VelociRaptor','300 GB',229.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('ST31000528AS','Seagate Barracuda','1 TB',99.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('ST3250310AS','Seagate Barracuda','250 GB',47.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('WD10EADS','Western Digital Caviar Green','1 TB',89.99)");

    What did I tell you about not using Access?
    This is exactly why. This is an Access related issue, and one that has been discussed many times previously on this site.
    Choose. Another. Database.

  • Insert into various databases

    Yeah ,
    I havent tried this in oracle .I know this is possible in sqlserver how about in Oracle.
    I have two databases like DB1 and Db2 with a table emp .
    now i am connected to Db1 and
    Can i give an insert statement like
    Inset into DB2.SCOTT.EMP (NO,NAME) values (1,'james');
    can i do all the dml operations by logged into Db1 and doing DML operations in DB1.
    will this be possible in oracle.

    yeah
    as per ur link i have been suceesful upto here
    I am stuck here
    SQL> CREATE or REPLACE TRIGGER MoveQuoteOrderHeader
    2 AFTER INSERT ON Quote FOR EACH ROW
    3 begin
    4 INSERT INTO ORDERHEADER@test1
    5 (SourceQuoteId,SourceCustomerName,SourceCustomerId,CreateDate,Status,Source
    Comment)
    6 values
    7 (new.QuoteNumber,new.name,new.AccountId,new.StartDate,new.status,new.commen
    ts);
    8 end;
    9 /
    Warning: Trigger created with compilation errors.
    SQL> sho err;
    Errors for TRIGGER MOVEQUOTEORDERHEADER:
    LINE/COL ERROR
    2/1 PL/SQL: SQL Statement ignored
    5/70 PL/SQL: ORA-00984: column not allowed here
    what may be wrong here the statements are correct .

  • Insert into SQL2008 Database

    Hi there
    I want to be able to check the disk space and if the backups have run sucessfully on mac,
    and be able collect this data and insert into our 2008r2 server on which SQL2008 is running.
    Can you please point me to some script and the best way to do it.
    Kind Regards
    Gorilla Tech

    Many thanks for your help etresoft, can anyone please point me to any Perl scripts links please.

  • UDF JDBC -- want to insert into a database

    Hi experts,
    I need to insert into a DB using a UDF. I have written the UDF but the problem is it works fine for a select query and when i replace the query with insert, it fails.
    the JDBC CC says invalid SQL query.
    The 2 queries are :
    //insertQuery= "insert into TABLENAME (COLUMNNAME) values ('"VAR"')";
    //insertQuery= "select count(*) from TABLENAME";
    accessor = LookupService.getDataBaseAccessor(channel);
    resultSet = accessor.execute(insertQuery);
    Also if I execute the insert query in DB it works fine.
    Please advise.

    It is a very simple thing i am doing..........................
    i have a source structure in which the first field of the source is the input to the first field of the target.
    there is a UDF in between which inserts the first source field. the UDF has the channel specified which is  JDBC.
    I was just running it thru the display queue (in MM) at the  and checking the communication channel. It gets errored out......... saying invalid SQL statement. But for select query it works fine

  • How to insert the Formatted date value and insert into the database

    Hi All,
    I am having requirement of inserting the date value in to the datbase. I'm already getting the value from file as MM-DD-YYYY. Getting exception while transforming the values through the transform activity. I'm using format fate function but it is inserting null value in to the database.
    Any help from anyone would bve appreciated.
    Thanks,
    CH

    Hi,
    your input date format is fixed right? So, in the transform you can split each your date, which is in 'MM-DD-YYYY' format ... extract day, month, year.
    After that ... just put these values in order acording to the format of 'xsd:date' data type which is '[-]CCYY-MM-DDZ'.
    XPath function 'xp20:format-dateTime()' works only with 'xsd:dateTime' data type, which has format '[-]CCYY-MM-DDThh:mm:ssZ'.
    So, in your case it could be:
    <xsl:variable name="day" select="substring($inputDate,4,2)"/>
    <xsl:variable name="month" select="substring($inputDate,1,2)"/>
    <xsl:variable name="day" select="substring($inputDate,7,4)"/>
    <xsl:variable name="outputDate">
    <xsl:value-of select="$year"/>
    <xsl:text>-</xsl:text>
    <xsl:value-of select="$month"/>
    <xsl:text>-</xsl:text>
    <xsl:value-of select="$day"/>
    </xsl:variable>
    Regards,
    Martin.

  • Inserting a new record in  a database

    Hi,
    In my program I have to add a new record in a database. The problem is that one of the column of the database is a MEDIUMBLOB, and I have to put into that column an array of byte ( that I can convert into an InputStream ).
    How can I do?

    To insert Blob data (an array of byte called "data") I tryed the following code; the blob colomn is called "column2" and the table(called "myTable") has only another column ("column1"), a column of String:
    InputStream inp = new ByteArrayInputStream(data);
    stmt.executeUpdate("insert into myTable (column1)
    values( ' value1' ); " );
    ResultSet res = stmt.executeQuery("select column2 from myTable");
    res.updateBlob("data", inp);The problem is that I have the following error:
    Exception in thread "AWT-EventQueue-0" java.lang.AbstractMethodError: >com.mysql.jdbc.ResultSet.updateBlob(Ljava/lang/String;Ljava/io/InputStream;)V

  • Insert a new record in the database table in between the records.

    i va a database table which ve 100 records. but i want to insert my new record  as 50th record. how i want to  proceed?
    thanks ,
    velu.

    V,
    This is an odd request.  Why?
    Ignoring that, you can ATTEMPT to insert into the 50th position IF:
    1) The DB table has just had the primary key index re-built/re-shuffled to GUARANTEE that it IS in primary key order
    2) And the primary key of the new record is built so that it follows the 49th record
    Regardless, once this table has activity against it, its sort order can/will get out of promary key order (with adds/changes/deletes). 
    But when you select data from it, you can use ORDER BY or an ABAP SORT to organzie the date as needed.
    Again... not sure WHY you need a record in a particular physical position... who cares... it is a relational DB.

Maybe you are looking for