• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Writing values to Excel from Applet

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All Pls help me i dont know what is wrong i am coding as below for testing the connection between applet and excel,i get error while making the dsn connection that is in DriverManager.getConnection("jdbc dbc:Excel Files"); as below.
java.sql.SQLException: No data found
Excel Files dsn is default user dsn in odbc for Excel. i even tried by making a new system dsn and user dsn even then i get the same error can any one guide me. pls it is urgent.......
I want to write the data to excel from Applet
import java.sql.*;
public class excelWrite
{
public static void main(String args[]) {
Connection conn=null;
Statement stmt=null;
String sql="";
ResultSet rs=null;
String srno="10";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println(" "+Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"));
conn=DriverManager.getConnection("jdbc dbc:Excel Files");
stmt=conn.createStatement();
//sql="INSERT INTO [Sheet1$](srno,test,description,output,output1,pass) VALUES ('1','Hari','Venke','Vasan','Swami','Shalin')";
//int i =stmt.executeUpdate(sql);
}
catch (Exception e){
System.err.println(e);
}
finally {
try{
rs.close();
stmt.close();
conn.close();
rs=null;
stmt=null;
conn=null;
}
catch(Exception e){}
}
}
}
 
Manikandan Kasirajan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.sql.*;
public class excelWrite
{
public static void main(String args[]) {
Connection conn=null;
Statement stmt=null;
String sql="";
ResultSet rs=null;
String srno="10";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
System.out.println(" "+Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"));
conn=DriverManager.getConnection("jdbc dbc:Excel Files","","");
stmt=conn.createStatement();
sql = "CREATE TABLE [Sheet1$] (srno TEXT,test TEXT,description TEXT,output TEXT,output1 TEXT,pass TEXT)";
boolean b=stmt.execute(sql);
sql="INSERT INTO [Sheet1$](srno,test,description,output,output1,pass) VALUES ('1','Hari','Venke','Vasan','Swami','Shalin')";
int i =stmt.executeUpdate(sql);
}
catch (Exception e){
System.err.println(e);
}
finally {
try{
// rs.close();
// stmt.close();
//conn.close();
rs=null;
stmt=null;
conn=null;
}
catch(Exception e){}
}
}
}

this code works fine and inserts data into the excel file but it happens only when the USER DSN is assigned to a excel sheet and when it is open.
My program is a client server program,And user is just a lay man and he can not set the odbc settings for excelsheet,Is there any method where i can make it happen dynamically like open a excel file from applet and write the values to the spread sheet.
Pls help
 
reply
    Bookmark Topic Watch Topic
  • New Topic