473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

How to insert rows in sql database from excel?

Hi!
I don't have a clue how to solve this problem in a simple way. I'm using a jdbc driver. The task is to compare rows in the excel sheet and insert them if they don't exists in the database. How can i do this? :S

Very graceful for any answer i can get :)

//Diana
Jan 28 '08 #1
8 3541
r035198x
13,262 8TB
Hi!
I don't have a clue how to solve this problem in a simple way. I'm using a jdbc driver. The task is to compare rows in the excel sheet and insert them if they don't exists in the database. How can i do this? :S

Very graceful for any answer i can get :)

//Diana
Your best bet is to split the problem into steps.
First you need to be able to read an excel document.
Then you need to be able to read data from a database.
The third step is the comparison between the data from the excel sheet and what's already in the database.
Finally you need to be able to perform insert statement on the database.

If you know JDBC then the problem is as good as solved.
Is there any particular step that you are stuck on now?
Jan 28 '08 #2
BigDaddyLH
1,216 Expert 1GB
Hi!
I don't have a clue how to solve this problem in a simple way. I'm using a jdbc driver. The task is to compare rows in the excel sheet and insert them if they don't exists in the database. How can i do this? :S

Very graceful for any answer i can get :)

//Diana
The first step is to break the problem into pieces and analyze each piece. I see at least three steps:

1. Reading from an Excel spreadsheet
2. Comparing row data
3. Database operations

edit: punchbug!
Jan 28 '08 #3
r035198x
13,262 8TB
...

edit: punchbug!
And I was typing the whole thing in zero's and ones too ...
Jan 28 '08 #4
BigDaddyLH
1,216 Expert 1GB
And I was typing the whole thing in zero's and ones too ...
Typing? You have a keyboard? Luxury! I did it all by connecting and unconnecting cables. But try telling that to young people today...
Jan 28 '08 #5
Hi again :)
I can read from the exceldocument and from the database but i don't know how to store the data from the excelsheet (should i keep it in a array or something? :S) and then how I write the current string from the excel into the database?

/diana
Jan 29 '08 #6
r035198x
13,262 8TB
Hi again :)
I can read from the exceldocument and from the database but i don't know how to store the data from the excelsheet (should i keep it in a array or something? :S) and then how I write the current string from the excel into the database?

/diana
You can keep the data in any structure you want. Probably in dynamic collections.
For writing to the database, just do something similar to what you did to read the data, only this time you use executeUpdate instead of executeQuery. Just check the API docs for those methods.
Jan 29 '08 #7
BigDaddyLH
1,216 Expert 1GB
On the database side, it sounds like you don't know about JDBC. Take the tutorial:

http://java.sun.com/docs/books/tutorial/jdbc/index.html
Jan 29 '08 #8
Ok thanks for the help, I'll read about the JDBC and then hope I'll understand it some more :)

/Diana
Jan 29 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: iqbal | last post by:
Hi all, We have an application through which we are bulk inserting rows into a view. The definition of the view is such that it selects columns from a table on a remote server. I have added the...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
2
by: Mansi | last post by:
I'm trying to automate excel from c#. One of the things I need to do is to copy/paste/insert rows in excel via c# code. I tried to do the following: 1) Select a row in excel (a12 to k12) 2)...
0
by: grego9 | last post by:
I am trying to insert a new blank row above any row in my excel spreadsheet that has the text "NO" in column O. The macro I have written (below) works fine - apart from when there are two or three...
6
by: grego9 | last post by:
I am trying to write some code to get Excel 2000 to insert a blank row wherever there is a "NO" in column O (above the NO). The code below nearly does this - but not quite!. The problem I have is...
7
by: InnoSol | last post by:
Hi all, I import MS Excel 2003 spread sheet in MS SQL Server 2000 through MS SQL Server 2000 Enterprise Manager. In excel two sheets (sheet1 and sheet2) of data is there. I imported first sheet...
1
by: accessvbanewbie | last post by:
I would like to export a recordset from access to excel but after each record is exported I want to insert a new row. The first recordset does this ok. However, the second recordset onwards does not...
1
by: Raymond Chiu | last post by:
Dear all, I try to insert new row under row 22 but it prompt error . Do you know how to correct? ----------------------------------------------------------------------- objSheet =...
0
by: premMS143 | last post by:
I've created a application using VB. Here, how to code to insert number of rows (user mentioned) in an existing excel worksheet ....? In this, User has prompted, 1. Select an existing excel file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.