|
-
Nov 12th, 2001, 01:23 PM
#1
Thread Starter
Fanatic Member
Simple Question.
Hi.
I'm new to java and I'm trying to run the following code.
VB Code:
import java.io.*;
import java.sql.*;
public class ExcelReadTest{
public static void main(String[] args){
Connection connection = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection( "jdbc:odbc:exceltest" );
Statement st = con.createStatement();
ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
while (rs.next()) {
for (int i = 1; i <= numberOfColumns; i++) {
if (i > 1) System.out.print(", ");
String columnValue = rs.getString(i);
System.out.print(columnValue);
}
System.out.println("");
}
st.close();
con.close();
} catch(Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
}
}
When I compile the code, I get this error message: JavaExcel.java:5: class ExcelReadTest is public, should be declared in a file named ExcelReadTest.java. How do I fix this?
Thanks in advance.
-
Nov 12th, 2001, 03:54 PM
#2
your .java file must be named ExcelReadTest.java (with the captialization, and everything)
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Nov 12th, 2001, 04:35 PM
#3
Thread Starter
Fanatic Member
Thanks crptcblade,
I said it was a simple question!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|