Insert into oracle DB using vb2005

I have a form that has click button1. The problem with this code is after insert command something should be inserted into oracle DB but nothing there(so how to execute insert command and commit it using VB2005), any suggestion should refer to the code.
Imports System
Imports System.Data ' VB.NET
Imports Oracle.DataAccess.Client ' ODP.NET Oracle data provider
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
'System.Data.OracleClient lets you access Oracle databases.
Public con As System.Data.OracleClient.OracleConnection = New System.Data.OracleClient.OracleConnection() 'Oracle.DataAccess.Client.OracleConnection()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim range As Excel.Range
Dim rCnt As Integer
Dim cCnt As Integer
Dim Obj As Object
xlApp = New Excel.ApplicationClass
xlApp.Visible = True
xlWorkBook = xlApp.Workbooks.Open("c:\employee.xls")
xlWorkSheet = xlWorkBook.Worksheets("sheet1")
range = xlWorkSheet.UsedRange
For rCnt = 2 To range.Rows.Count
For cCnt = 1 To range.Columns.Count
Obj = CType(range.Cells(rCnt, cCnt), Excel.Range)
'MsgBox(Obj.value)
Next
Next
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
End Sub
Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim daOracle As New OracleDataAdapter
Dim InsertCommand As New OracleCommand
daOracle.InsertCommand = New OracleCommand
'1.Create connection object to Oracle database
Dim con As OracleConnection = New OracleConnection()
Try
'2.Specify connection string
con.ConnectionString = ("Data Source=mgra;User Id=tmar; Password=grams")
'3. Open the connection through ODP.NET
con.Open()
Catch ex As Exception
'4.display if any error occurs
MsgBox(ex.Message, Microsoft.VisualBasic.MsgBoxStyle.Exclamation, "OraScan")
'3.Create command object to perform a query against the database:
Dim cmdQuery As String = "SELECT * FROM employee"
InsertCommand.CommandText = "insert into meta_objecttypes values(4,'table','table','ERStudio','Demo')"
daOracle.InsertCommand = InsertCommand
' Create the OracleCommand object to work with select
Dim cmd As OracleCommand = New OracleCommand(cmdQuery)
cmd.Connection = con
cmd.CommandType = CommandType.Text
'get the DataReader object from command object
Dim rdr As OracleDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
cmd.ExecuteNonQuery()
'check if it has any row
While rdr.Read()
rdr.Close()
End While
Finally
' Close and Dispose OracleConnection object
con.Close()
con.Dispose()
End Try
End Sub
End Class

For best results, please repost this to the ODP.NET forum.

Similar Messages

  • Can select, but cannot insert into oracle tables using php.

    I am having trouble inserting data into a tables in oracle using PHP. I can insert into the tables using baninst1, but nothing else. I can't even insert using the tables' owner. Every time I try I get the ORA-00492 error of table or view does not exist. However, I can run a select statement just fine. So far, baninst1 is the only user that can actually do inserts. I've triple checked all the table grants and everything is fine. Also, I can copy/paste the exact insert statement into SQL*Plus and it works with the correct user. It doesn't have to be baninst1. I've tried everything I can think of. I've tried putting the table name in quotes, adding the schema name to the table, checking public synonyms, but everything appears to be ok. I would greatly appreciate any suggestions others may have.
    I'm using PHP 5.2.3 with an oracle 9i DB.

    Here is the code that doesn't work. It works only with baninst1, no other username will work and all I do is change the my_username/my_password to something different. This is one example function where I try to do an insert, but it doesn't work on any of the tables I try.
    Thanks for looking.
    class Oracle {
         private $oracleUser = "my_username";
         private $oraclePassword = "my_password";
         private $oracleDB = "MY_DB";
         private $c = null;
         function Connect() {
              if ( !($this->c = ocilogon( $this->oracleUser, $this->oraclePassword, $this->oracleDB ) ) )
                   return false;
              return true;
         function AddNewTest($testName, $course, $section, $term, $maxAttempts, $length, $startDate, $startTime, $endDate, $endTime)
              $result = "";
              if( $this->c == null )
                   $this->Connect();     
              $splitIndex = strpos($course, " ");
              $subjectCode = substr($course, 0, $splitIndex);
              $courseNumber = substr($course, $splitIndex + 1);
              $insertStatment = "insert into szbtestinfo(szbtestinfo_test_name,
                                                                szbtestinfo_course_numb,
                                                           szbtestinfo_section,
                                                                szbtestinfo_max_attempts,
                                                                szbtestinfo_length_minutes,
                                                                szbtestinfo_start,
                                                                szbtestinfo_end,
                                                                szbtestinfo_id,
                                                                szbtestinfo_subj_code,
                                                                szbtestinfo_eff_term)
                                                                values( '" . $testName .
                   "', '" . $courseNumber .
                   "', '" . $section .
                   "', " . $maxAttempts .
                   ", " . $length .
                   ", to_date('" . $startDate . " " . $startTime . "', 'MM/DD/YYYY HH24:MI')" .
                   ", to_date('" . $endDate . " " . $endTime . "', 'MM/DD/YYYY HH24:MI')" .
                   ", szsnexttest.nextval" .
                   ", '" . $subjectCode .
                   "', '" . $term . "')";
              //return $insertStatment;
              $s = OCIParse($this->c, $insertStatment);
              try
                   $result = OCIExecute($s);
              catch(exception $e)
              return $result;
         }

  • Unable to insert into oracle db using times ten

    I have a times ten 6.0 installation on my m/c connected to an oracle 10.2.0.2 database. The database is a remote database. My application is deployed to oracle application server (10.1.3.1 SOA). I am getting the following SQLException when I try to insert.the first row.
    java.sql.SQLException: [TimesTen][TimesTen 6.0.4 ODBC Driver][TimesTen]TT5105: OCI initialization failed. -- file "bdbEnv.c", lineno 275, procedure "ttBDbEnvAlloc"
    My env is as follows
    OS = Windows 2000
    DataSource = User DSN
    First Connection
    Permanent Data Store = 100
    Temporary Data Store = 50
    Connections = 20
    Synchronous write through cache
    I tried a select on the table before insert and it worked. Using ttisql I can insert into this table without any problem. Using a standalone java program I am able to insert data into this table. But from within an appserver I am facing this issue.
    Thanks in advance for any help.
    Regards,
    Mahesh.

    Jimmyb,
    Are you logged in as the user that owns that table?
    Yes.
    If yes, then there are no triggers on this table.
    That is true.
    You will need to populate the ID column with your insert statement.
    Just did that.
    Usually, the sequence is very similar to the table name.
    Yes I tried few of them in my sql query and it said "sequence cannot be found"
    Isn't there some way that it will list the name of the sequence currently being used in a table?

  • 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 oracle lob using php odbc

    is there a way to insert a string > 4000 characters into an oracle lob using php without using oci8 extension? If so can somebody post some sample code to do it?

    Perhaps you could externally invoke Oracle's SQL Loader utility.
    What are you trying to achieve?
    -- cj

  • Issue of inserting greek characters into Oracle database using ICAN505

    Hi All,
    We are currently facing an issue of inserting greek characters into Oracle database using ICAN505.
    We receive a file containing greek characters.The values from the file should be inserted into the database.We are reading the file using file OTD with default encoding.
    The file can contain english characters too other than greek characters.
    The database NLS_CHARACTERSET is AL32UTF8.
    When I insert using an insert statement directly ,the values get inserted properly into the DB table.
    Inserting the same values using code results in improper characters getting inserted into the table in the database.
    Please help....
    Thanks in advance !!

    Globalization forum?
    Globalization Support
    It works for SQL Developer, which does not depend on NLS_LANG, so I suspect a problem with your NLS settings.

  • Bulk insert into oracle using ssis

    Hi ,
    Can someone please suggest me the way to Bulk insert data into oracle database? I'm using oledb which doesnt support bulk insert into oracle.
    Pls note I cant use Oracle ATTUnity as it requires enterprise edition but i have only Standard edition and hence that option is ruled out.
    Is there any other way that I can accompolish BULK insert?
    Please help me out.
    Thanks,
    Prabhu

    Hi Prabhu,
    I am very late to help you solve the query but following is the solution to 'Bulk Insert into Oracle' that worked for me.
    To use below code for SSIS 2008 R2 in a
    Script Task component you would need following API references.
    Prerequisites:
    1. C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SQLServer.DTSRuntimeWrap.dll
    2. Install "Oracle Data Provider For .NET 11.2.0.1.0" and add a reference to
    Oracle.DataAccess.dll.
       Microsoft SQL Server Integration Services Script Task
       Write scripts using Microsoft Visual C# 2008.
       The ScriptMain is the entry point class of the script.
     *  Description : SQL to Oracle Bulk Copy/Insert
     *  Created By  : Mitulkumar Brahmbhatt
     *  Created Date: 08/14/2014
     *  Modified Date   Modified By     Description
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using Oracle.DataAccess.Client;
    using Microsoft.SqlServer.Dts.Runtime.Wrapper;
    using System.Data.OleDb;
    namespace ST_6e18a76102dd4312868504c4ef95279d.csproj
        [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
            #region VSTA generated code
            enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
                Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
            #endregion
            public void Main()
                ConnectionManager cm;
                IDTSConnectionManagerDatabaseParameters100 cmParams;
                OleDbConnection oledbConn;
                DataSet ds = new DataSet();
                string sql;
                try
                    /********** Pull Sql Source Data into a Dataset *************/
                    cm = Dts.Connections["SRC_CONN"];
                    cmParams = cm.InnerObject as IDTSConnectionManagerDatabaseParameters100;
                    oledbConn = (OleDbConnection)cmParams.GetConnectionForSchema() as OleDbConnection;
                    sql = @"Select * from [sourcetblname]'';
                    OleDbCommand sqlComm = new OleDbCommand(sql, oledbConn);
                    OleDbDataAdapter da = new OleDbDataAdapter(sqlComm);
                    da.Fill(ds);
                    cm.ReleaseConnection(oledbConn);
                    /***************** Bulk Insert to Oracle *********************/
                    cm = Dts.Connections["DEST_CONN"];
                    cmParams = cm.InnerObject as IDTSConnectionManagerDatabaseParameters100;
                    string connStr = ((OleDbConnection)cmParams.GetConnectionForSchema() as OleDbConnection).ConnectionString;
                    cm.ReleaseConnection(oledbConn);
                    sql = "destinationtblname";
                    using (OracleBulkCopy bulkCopy = new OracleBulkCopy(connStr.Replace("Provider=OraOLEDB.Oracle.1", "")))
                        bulkCopy.DestinationTableName = sql;
                        bulkCopy.BatchSize = 50000;
                        bulkCopy.BulkCopyTimeout = 20000;
                        bulkCopy.WriteToServer(ds.Tables[0]);
                    /***************** Return Result - Success *********************/
                    Dts.TaskResult = (int)ScriptResults.Success;
                catch (Exception x)
                    Dts.Events.FireError(0, "BulkCopyToOracle", x.Message, String.Empty, 0);
                    Dts.TaskResult = (int)ScriptResults.Failure;
                finally
                    ds.Dispose();
    Mitulkumar Brahmbhatt | Please mark the post(s) that answered your question.

  • How to extract data from xml and insert into Oracle table

    Hi,
    I have a large xml file. which will have hundreds of the following transaction tags having column names and there values.
    There is a table one of the schema with coulums "actualCostRate","billRate"....etc.
    I need to extract the values of these columns and insert into the table
    <Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuUK" chargeCode="LCOCD1" externalID="L-RESCODE_UK1-PROJ_UK_CNT_GBP-37289-8" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-12" transactionType="L" units="11" taskID="5017601" inputTypeCode="SALES" groupId="123" voucherNumber="ABCVDD" transactionClass="ABCD"/>
    <Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuEU" chargeCode="LCOCD1" externalID="L-RESCODE_US1-PROJ_EU_STD2-37291-4" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-04" transactionType="L" units="4" taskID="5017601" inputTypeCode="SALES" groupId="124" voucherNumber="EEE222" transactionClass="DEFG"/>

    Re: Insert from XML to relational table
    http://www.google.ae/search?hl=ar&q=extract+data+from+xml+and+insert+into+Oracle+table+&btnG=%D8%A8%D8%AD%D8%AB+Google&meta=

  • XML data insert into Oracle

    Hi all,
    I have some xml data which i would like to insert into oracle tables.
    Where to start up with this?

    Hi,
    Here's another good place to start: [XML DB FAQ|http://forums.oracle.com/forums/thread.jspa?threadID=410714&tstart=0]
    You seem to be especially interested in second post in there.
    Regards
    Peter

  • How to read the data from XML file and insert into oracle DB

    Hi All,
    I have below require ment.
    I will receive data in the XML file. then i need to read that data and insert into oracle tables. please let me know how this can be handled.
    Many Thanks.

    Sounds a lot like this question, only with less details.
    how to read data from XML  variable and insert into table variable
    We can only help if you provide us details to help as we cannot see what you are doing and only know what you tell us.  Plenty of examples abound on the forums that cover the topics you seek as well.

  • Help Required :Excel Upload Into Oracle Table Using PLSQL Procedure/Package

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    I also Tried to Use This
    But How can i Use SQLLDR Command In Stored Procedure.
    Well IN SQL*PlUS it is successfull but in Stored Procedure /Package ,PL/SQL does not recognise the OS commands.
    So now my Question How can I recognise the SQLLDR Commnad in Stored Procedure.

  • Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
    If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
    If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
    Justin

  • Insert data into oracle database using a PHP form

    I'm trying to enter data into my oracle database table using a php form. When I click submit no data is added. Could someone help me please. I'm new to php/oracle thing.
    NOTE: I don't have any problem connecting to the database using php.
    Here is the code I'm using:
    <?php
    // just print form asking for name if none was entered
    if( !isset($query)) {   
    echo "<form action=\"$uri\" method=post>\n";
    echo "<p>Enter Name: ";
    echo "<input type=text size=100 maxlength=200 name=data value=\"$data\">\n";
    echo "<br><input type=submit name=submit value=Submit>\n";
    echo "</form>\n";
    exit;
    // insert client's name
    $query = "INSERT INTO client (name) VALUES ($data)";
    // connect to Oracle
    $username = "xxxx";
    $paswd = "yyyyyy";
    $dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
    "(HOST=patriot.gmu.edu)(PORT=1521))".
    "(CONNECT_DATA=(SID=COSC)))";
    $db_conn = ocilogon($username, $paswd, $dbstring);
    $stmt = OCIParse($db_conn, $query);
    OCIExecute($stmt, OCI_DEFAULT);
    OCIFreeStatement($stmt);
    OCILogoff($db_conn);
    ?>
    Thanks for your help. I will also appreciate a better was to do it.
    Tony

    resumption and jer,
    Sorry I cannot format the code for easy reading!
    The page is submitting to itself. See action = \"$uri\". I used the same logic to enter SELECT querries into the database. It pulls and displays data back on the webpage. The code I used for this is below. Compare it with the one above for inserting data into the table.
    <?php
    // connect to oracle
    $username = "xxxxx";
         $paswd = "yyyyy";
         $dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
              "(HOST=patriot.gmu.edu)(PORT=1521))".
              "(CONNECT_DATA=(SID=COSC)))";
         $db_conn = ocilogon($username, $paswd, $dbstring);
    // username and password will be unset if they weren't passed,
    // or if they were wrong
    if( !isset($query)) {
    // just print form asking for account details
    echo "<form action=\"$uri\" method=post>\n";
    echo "<p>Enter Query: ";
    echo "<input type=text size=100 maxlength=200 name=query value=\"$query\">\n";
    echo "<br><input type=submit name=submit value=Submit>\n";
    echo "</form>\n";
    exit;
    // remove unwanted slashes from the query
    $query = stripslashes($query);
    // run the query
    $stmt = OCIParse($db_conn, $query);
    OCIExecute($stmt, OCI_DEFAULT);
    // Open the HTML table.
    print '<table border="1" cellspacing="0" cellpadding="3">';
    // Read fetched headers.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="e">'.ocicolumnname($stmt,$i).'</td>';
    print '</tr>';
    // Read fetched data.
    while (ocifetch($stmt))
    // Print open and close HTML row tags and columns data.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="v">'.ociresult($stmt,$i).'</td>';
    print '</tr>';
    // Close the HTML table.
    print '</table>';
    OCIFreeStatement($stmt);
    OCILogoff($db_conn);
    ?>

  • Inserting Multiple Images into oracle database using JDBC

    I wanted to insert multiple images into database using JDBC by reading it from the file... and i am passing photos.txt(my text file) as an input parameter... I have inserted all the values into the database except for the image part... this is my content of photos.txt file and i have copied all the images into the folder
    *" C:\\photos "*
    *1,in1.jpg,108,19,in-n-out*
    *2,in2.jpg,187,21,in-n-out*
    *3,in3.jpg,308,41,in-n-out*
    *4,in4.jpg,477,52,in-n-out*
    *5,in5.jpg,530,50,in-n-out*
    and i want to store in1.jpg,in2.jpg,in3.jpg,in4.jpg,in5.jpg into the oracle databse using JDBC.... i have tried a lot using BLOB column.... and i have created my table as
    CREATE TABLE PHOTO(
    ID NUMBER NOT NULL PRIMARY KEY ,
    Name BLOB,
    X DOUBLE PRECISION,
    Y DOUBLE PRECISION,
    Tags VARCHAR2(40)
      try {                 // for restaurant System.out.println();System.out.println();System.out.println(); System.out.print("  Creating Statement for Photo...\n");             stmt2 = con.createStatement ();                       stmt2.executeUpdate("delete from PHOTO"); stmt2.executeUpdate("commit"); PreparedStatement stmt3 = con.prepareStatement ("INSERT INTO PHOTO VALUES (?, ?, ?, ?, ?)");             System.out.print("  Create FileReader Object for file: " + inputFileName1 + "...\n");             FileReader inputFileReader2 = new FileReader(inputFileName1);             System.out.print("  Create BufferedReader Object for FileReader Object...\n");             BufferedReader inputStream2  = new BufferedReader(inputFileReader2);             String inLine2 = null;                         String[] tokens; //            String[] imageFilenames = {"c:\\photos\\in1.jpg","c:\\photos\\in2.jpg","c:\\photos\\in3.jpg","c:\\photos\\in4.jpg","c:\\photos\\in5.jpg", //  "c:\\photos\\in6.jpg","c:\\photos\\in7.jpg","c:\\photos\\in8.jpg","c:\\photos\\in9.jpg","c:\\photos\\in10.jpg","c:\\photos\\arb1.jpg","c:\\photos\\arb2.jpg", //  "c:\\photos\\arb3.jpg","c:\\photos\\arb4.jpg","c:\\photos\\arb5.jpg","c:\\photos\\den1.jpg","c:\\photos\\den2.jpg","c:\\photos\\den3.jpg", //  "c:\\photos\\den4.jpg","c:\\photos\\den5.jpg","c:\\photos\\hop1.jpg","c:\\photos\\hop2.jpg","c:\\photos\\hop3.jpg","c:\\photos\\hop4.jpg","c:\\photos\\hop5.jpg"};               File file = new File("C:\\photos\\in1.jpg");            \\ ( Just for example  )           FileInputStream fs = new FileInputStream(file);                         while ((inLine2 = inputStream2.readLine()) != null) {               tokens= inLine2.split(",");             st2 = new StringTokenizer(inLine2, DELIM);                                                             stmt3.setString(1, tokens[0]);               stmt3.setBinaryStream(2, fs, (int)(file.length()));               stmt3.setString(3, tokens[2]);               stmt3.setString(4, tokens[3]);               stmt3.setString(5, tokens[4]);               stmt3.execute(); //execute the prepared statement               stmt3.clearParameters(); 
    As i am able to enter one image file by above code in1.jpg in to the oracle database.... but i am not able to insert all the image file in to the database.....do tell me what should i do.... and can you give me the example on the basis of the above code of mine...
    do reply as soon as possible..

    jwenting wrote:
    that depends. Putting the images in BLOBs prevents the file locations stored in the database from getting out of synch with the filesystem when sysadmins decide to reorganise directory structures or "archive" "old" files that noone uses anyway.True, but it really comes down to a business decision (cost-benefit analysis). If you have the bucks, the expertise, and the time, go with the Blobs, otherwise go with the flat files.

  • Best Practice to fetch SQL Server data and Insert into Oracle Tables

    Hello,
    I want to read sqlserver data everry half an hour and write into oracle tables ( in two different databases). What is the best practice for doing this?
    We do not have any database dblinks from oracle to sqlserver and vice versa.
    Any help is highly appreciable?
    Thanks

    Well, that's easy:
    use a TimerTask to do the following every half an hour:
    - open a connection to sql server
    - open two connections to the oracle databases
    - for each row you read from the sql server, do the inserts into the oracle databases
    - commit
    - close all connections

Maybe you are looking for