aspose file tools*
The moose likes JDBC and the fly likes java with excel using JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java with excel using JDBC" Watch "java with excel using JDBC" New topic
Author

java with excel using JDBC

kalaiselvi Bhalerao
Greenhorn

Joined: Aug 19, 2011
Posts: 9
Hi All

I need to develop a java application to connect with excel using type 4 jdbc driver.
I surfed the net for tutorials but i did not find any.

I have downloaded the Excel_JDBC40.jar file and connected to excel using jdbc connection.


but i am stuck up and have no idea what next has to be done.

It would be greatful if some can help me.

regrads
s.kalaiselvi
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30548
    
152

I've added code tags to make the code easier to read.

Are you getting an error with that code? If so, what is it? If not, the next step is to add ResultSet code. You loop through the result set and call getters for each column.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Wei Dai
Ranch Hand

Joined: Jun 22, 2005
Posts: 86
<quote>
I need to develop a java application to connect with excel using type 4 jdbc driver.
I surfed the net for tutorials but i did not find any.
</quote>
It's at HXTT Excel JDBC document

>but i am stuck up and have no idea what next has to be done.
You can find some *.java which is sample to create ResultSet
For instance,
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()) {
System.out.println(rs.getString(1));
}
Or
ResultSetMetaData resultSetMetaData = rs.getMetaData();
int iNumCols = resultSetMetaData.getColumnCount();
for (int i = 1; i <= iNumCols; i++) {
System.out.println(resultSetMetaData.getColumnLabel(i)
+ " " +
resultSetMetaData.getColumnTypeName(i));
}

Object colval;
while (rs.next()) {
for (int i = 1; i <= iNumCols; i++) {
colval = rs.getObject(i);
System.out.print(colval + " " + "\t");
}
System.out.println();
}


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

I'd actually use Apache POI, JExcelAPI or some other library for reading Excel files. To me, Excel files are not database files, and therefore JDBC should not be used to read them.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java with excel using JDBC