Help me in MS-Access-Java-MS-Excel combination

i have to read a spreadsheet using Java & store in Access. my code is unable to do that,so modify the given java code for the above requirements. Don't import the spreadsheet directly from Excel to Access.
// The Java Code.
import java.sql.*;
import java.io.*;
class linkrec{
public static void main(String args[]) throws IOException {
for(int j=0;j<1;j++){
InputStream f= new FileInputStream("D:\\Backup\\BACK UP OF SCADA\\avt\\csv.dat");
int i;
do{  i=f.read();
     if(i!= -1)
     System.out.print((char) i);
}while(i!= -1); //End OF Do-While Loop.
f.close();
} //End Of For Loop
class connect throws IOException {
public void connect (int f){
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:dacc");
Statement stmt = con.createStatement();
//stmt.executeUpdate("insert into sheet2 values(10:10,48.20,01556,01129,00177,00400,04076,01668,01336,02830)");
stmt.executeUpdate("insert into sheet2 values(f)");
ResultSet rs = stmt.executeQuery("select * from sheet2");
while(rs.next())
     double Mytime = rs.getDouble(1);
     double Gridfreq= rs.getDouble(2);
     int ntpc_gen = rs.getInt(3);
     int nlcii_gen = rs.getInt(4);
     int maps_gen = rs.getInt(5);
     int kaps_gen = rs.getInt(6);
     int ap_gen = rs.getInt(7);
     int kar_gen= rs.getInt(8);
     int ker_gen = rs.getInt(9);
     int tn_gen = rs.getInt(10);
     stmt.close();
     con.close();
     System.out.println("Records Successfully Inserted");
     }catch(Exception e)
     e.printStackTrace();
// The spreadsheet of Excel.
MYTIME,GRID_FREQ,NTPC_GEN,NLCII_GEN,MAPS_GEN,KAPS_GEN,AP_GEN,KAR_GEN,KER_GEN,TN_GEN,AP_DEM,KAR_DEM,KER_DEM,TN_DEM,PONDY_DEM,GOVA_DEM,AP_DWL,KER_DWL,TN_DWL,PDY_DWL,GOA_DWL,AP_SCH,KAR_SCH,KER_SCH,TN_SCH,PDY_SCH,GOVA_SCH,EAST_GZK_EXC,EAST_USIL_EXC,WEST_RDM_EXC,WEST_AMD_EXC
2/8/01
10:10,48.20,01556,01129,00177,00400,04076,01668,01336,02830,04834,02528,01671,04093,00106,00120,00757,00860,00335,01263,00106,00120,01042,00736,00378,00982,00154,00070,00474,00000,-0000,00000

Here's how I would do it - since I don't know the datatypes of the columns in your access database I will assume that MY_TIME is a String value, GRID_FREQ is a Double and the rest are Integers. You can then modify the parsing as you wish if the datatypes are different.
Connection conn = null;
BufferedReader reader = null;
try
  reader = new BufferedReader(new FileReader(filename));
  // First line contains names of columns so just skip that
  reader.readLine();
  StringBuffer sql = new StringBuffer();
  sql.append("INSERT INTO sheet2 (");
  sql.append("MY_TIME,");
  sql.append("GRID_FREQ,");
  // put the rest of the column names in here!
  sql.append(") VALUES (");
  // change this to have one '?' for each column
  sql.append("?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ..., ?");
  sql.append(")");
  conn = DriverManager.getConnection(...);
  PreparedStatement pstmt = conn.prepareStatement(sql.toString());
  // Read in the rest of the lines from the file - inserting a row for each
  String line;
  while(true)
    line = reader.readLine();
    st = new StringTokenizer(line, ",", false);
    // set up the statement for creating the new row
    pstmt.setString(1, st.nextToken());
    pstmt.setDouble(2, Double.parseDouble(st.nextToken()));
    pstmt.setInt(3, Integer.parseInt(st.nextToken()));
    // etc for all the other columns you need to read
    // create the row
    pstmt.executeUpdate();
finally
  try
    reader.close();
  catch(Exception e)
  try
    conn.close();
  catch(Exception e)
}I've not tried it so you might need to experiment to get it to work. If you don't understand any of it just ask.
Hope this helps.

Similar Messages

  • HT6114 since I downloaded the OSX mavericks, I can no longer access word and excel

    Please help, I can not access word or excel after downloading the OS X mavericks software

    I upgraded to 10.9 and everything (including attaching Excel and Word files to Apple Mail as an attachment) works just fine.
    It does not work if you use Outlook instead of Apple mail.
    Reinstall Office.

  • Help attempting connect to network which requires Cisco Clean Access Java

    Wondering if someone could help me out. Attempting to access work network which requires Cisco Clean access Java applet. It gives me a link to Java. Question is does the itouch support java plug ins? Any thoughts gratefully appreciated.

    I ran into the same issue on my university campus. This is what I learned. Apparently, iPod Touch has wi-fi 802.11 and does not support 802.1x authentication method, which some universities and workplaces use. I do not know if there is (or will be) a solution. Hope that helps.

  • Error occurred while accessing application id Excel services application unattended service account from secure store service

    Hi,
      I follow up the book "Professional SharePoint 2013 Administration" to build the SharePoint 2013 BI include Excel Services. and created the Secure Store services to save the user SP_Install for member.
    For Now, I can upload the worksheet and open it in browser, but when I tried to refresh it, the SP 2013 show error "Error occurred while accessing application id Excel services application unattended service account from secure store service".
     does anybody can help ? and do I need to turn on C2WTS ? 
    Thanks
    James Liang

    Hi James,
    Excel Services can be used with Secure Store in three primary scenarios:
    Unattended Service Account
    Embedded Connections
    External Data Connections
    If you haven't configure unattended service account yet, you could refer to the article below:
    http://technet.microsoft.com/en-us/library/hh525344(v=office.15).aspx
    More information:
    http://technet.microsoft.com/en-us/library/ff191191(v=office.15).aspx
    Regards,
    Rebecca Tu
    TechNet Community Support

  • How to access java method in JSP

    Hi all,
    I need to access java class (abstract portal component) method doContent() in a JSP which is under PORTAL-INF/jsp folder.
    I did
    <%@ page import = "com.mycompany.Aclass" %>
    <%com.mycompany.Aclass a = new com.mycompany.Aclass (); %>
    Aclass is coming as autofill/prepopulated with cntrl+space
    Till this time, it is working. no errors. But when I do
    a.
    a. (a dot) no methods are populating (autofill..cntrl+space) or If I forcebly add method a.doContent(req,res)... at runtime its giving error.
    It's not only with doContent method... Its with any simple methods in that class or any other class.
    (Other than doContent method in the APC java class are prepopulating/autofilling but giving error in runtime)
    Can anyone help me... how to access java method in JSP.
    I already gone through many SDN forum post... and implemented too---but no use I refered below forum thread
    Retrieve values from Java class to JSP
    URGENT! How to call a java class from JSP.
    Calling a java method from jsp file -
    this thread is same as my issue
    Thanks,
    PradeeP

    1st. The classes must be in packages. 2nd, the package that they are in must be under the WEB-INF/classes directory. 3rd Look on google and/or this site for web application deployment

  • Accessing Control in Excel Worksheet

    My company has a Winforms App written in VB.Net that populates textboxes in a Excel 2010 Worksheet. This application has been working flawlessly since the days of Office 2003. Last week, several updates for Office and Excel were pushed out by Microsoft and
    my user community installed them. Since then, when our Winforms App attempts to populate the textboxes, the following kind of error occurs:
         "Public member 'txtVENDOR_NOTE' on type 'Worksheet' not found."
    I have verified that the text boxes exist in the worksheets and I have recreated the worksheets in Excel 2010, but the problems continues to persist. I have uninstalled all the Excel updates as well as several of the Office updates, but the issue still continues.
    Has anyone else experienced this issue recently and, if so, how did you resolve it? Since this issue began after the last batch of Office and Excel updates were pushed out by Microsoft, which we installed on December 12th, does anyone know what update might
    have caused the above problem?
    Thanks in advance for your help.

    Dear All,
    The following updates blocked our Winforms VB.Net App from accessing controls in Excel:
    Security Update for Microsoft Office 2010
    KB2553154
    KB2553284
    KB2687423
    KB2850016
    Uninstalling these updates resolved our problems and allowed us to continue with our business and interactions with our customers and vendors.
    The purpose of these security updates follows:
    "A security vulnerability exists in Microsoft office 2012 64-Bit Edition that could allow arbitrary code to run when a maliciously modified file is opened. This update resolves that vulnerability."
    These updates need to be installed with caution.
    Regards!

  • Accessing java classes from javascript

    Hi,
    I have the following javascript function
    function testjava {   
        var myString = new java.lang.String("Hello world"); // line 1
        alert("len:"+myString.length()); // line 2
    }It gives me a error at line 1 saying "'java' is undefined" in IE browser 5.5 sp2. But, both the lines execute correctly in netscape 6.
    Can someone please help..
    Thanks,
    Vijay.

    It seems that IE 5.5 doesn't support accessing java classes in JavaScript, so try to install IE 6 to see if it works or maybe, you doesn't have installed propertly support for JVM in IE.

  • Problems converting access database to excel

    is there any method to convert access db to excel spreadsheet.
    currently i'm using a 'cheat' way of retrieving the results to a table and convert to excel using this:
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition","attachment; filename=\"file.xls\";");
    the problem is that i need to delete the records in the database after saving the the excel file. this method does not let me perform response.sendRedirect() method after saving as excel. so, after i retrieve the results into a table, i delete the records in the database and prompt the user to save the excel file. this is risky cos if the user select cancel when prompted to save, the records in the databse will long be gone.
    i need help if anyone could suggest a solution to this.
    1. another method to convert access db to excel spreadsheet , or
    2. the excel file will be saved automatically without having the user to click to save, or
    3. to be able to get to delete the db records after saving.
    i really need the help from you people. thanks.

    I find your problem description confusing.
    Here's what it sounds like you're saying:
    You've got records in an Access database to start with. A user makes a request to see records in a browser. You've got a servlet that queries the Access database using JDBC, turns the result set into a CSV file, sets the content type to "application/vnd.ms-excel", and then displays the response as an MS Excel spreadsheet in the browser.
    So far, so good?
    That sounds like one use case to me - call it "Query Database For Records".
    Then it sounds like you want to implement another use case - call it "Modify Database". You'd like to be able to let the client manipulate the Excel data you've sent down and then resynch with the database when they say they're done.
    Again, okay?
    If that's true, treat them like two separate cases. It sounds like you want to do a multipart file upload of the Excel data where you'd have your servlet take the uploaded data and insert it back into the Access database.
    If I understand you correctly, Access is your persistence mechanism. I don't understand why you'd want to update Access AND save the Excel file. I read this as "I want to have one data source of record with the latest info, and I happen to like sending it down to clients in an Excel spreadsheet because that's what they're used to seeing."
    I'm sure this doesn't help you solve your problem yet, but it might help my understanding of what you're really trying to do here. - MOD

  • Request help with restricting site access

    I have posted before, and received a mix of condescension and
    such, but I am okay with that. I know very little about web design,
    but I am willing to learn.
    I built a website for my lab (home.uchicago.edu/~beilock) and
    the professor for whom I work would like a password protected
    portion of the site. Previous advice led me to try PHP/MySQL (for a
    newbie like me, these terms were foreign), and I downloaded and
    followed all of Dreamweaver's help section and to no avail (it says
    cannot connect to FTP host)...and I have tried many things to fix
    that, but could not.
    Anyway, so this post is for multiple purposes. 1.
    Opinions/Advice on the website; 2. Solutions to my connection
    problem; 3. simpler alternatives to making a site restricted (I
    know nothing of ColdFusion, but if it is easier, please let me
    know)
    I don't mind being condescended to or berated if you help me
    out successfully, in fact, let that be your motivation.
    Any help appreciated,
    Jamie

    Use coldfusion it is the best out there/ quick and easy to
    learn. Check out easycfm.com (they have a great tutorial about
    security and restricting access)and post any questions there or on
    the adobe coldfusion forum.
    If you don[t know anything thenm the quickest language to
    learn is coldfusion. You then have to decide if you are going to
    use access database or mysql. If it is a huge site use mysql if not
    use access. Access is like excel and is easy to use, mysql you will
    need to use a program like navicat (google it) to connect to the db
    and be able to display it like access. They both come with nearly
    all hosts. Who does your hosting ask them how to connect via ftp.
    You will need a username, password and hostname as minimum. I
    imagine you arent trying to connect to RDS at this stage most hosts
    dont allow this(remote development)
    Well Good luck!!

  • How to communicate from java to excel?

    I need to pass data from java to excel such that it'll create a report.
    It should be able to handle images also. ie.
    I have a form which contains some data.
    I need to read the data from the form and export the data - in the same format in the form - to MSexcel. I should be able to put the data in specific cells of MSexcel.
    Please help.

    example:
    out.print("Line1");
    out.print(",col2");
    out.print(",col3");
    out.println("");
    out.print("col1 - line2");
    ...

  • Problem- Accessing java script code in java

    i want to access java script variable in java code.
    Is it possible through any method or function?
    help me.

    Stick to your old thread.
    http://forum.java.sun.com/thread.jspa?threadID=777985

  • I am still having problems accessing java script sites.  Anyone else having this problem?

    I am still having problems accessing java script sites.  Anyone else having this problem?

    Javascript can be left on, but Java (which is something very different) should generally be turned off.
    Apple barred Java from running on Macs, leaving companies that rely on Java plug-ins out in the cold.
    Apple blocked Java 7 Update 11 by adding it to the banned list in XProtect.
    This was the second time in two weeks that Apple has blocked Oracle's code from running on Macs. This time Java is blocked through Apple's XProtect anti-malware feature.
    Java has come under fire as the means by which hackers have been able to gain control of computers. In April 2012 more than 600,000 Macs were reported to have been infected with a Flashback Trojan horse that was being installed on people's computers with the help of Java exploits. Then in August Macs were again at risk due to a flaw in Java, this time around, there was good news for Mac users: Thanks to changes Apple has made, most of us were safe from the threat.
    Unwilling to leave its customers open to potential threats Apple decided it's safer to block Java entirely.
    Macs running OS X Snow Leopard and beyond are affected.
    UPDATE for those running Lion or Mountain Lion:
    Oracle on Friday February 1 released a new version reportedly addressing vulnerabilities seen with the last build.
    Apple disabled Java 7 through the OS X XProtect anti-malware system, requiring users to have at least version "1.7.0_10-b19" installed on their Macs. The release dated February 1 carries the designation "1.7.0_13-b20," meeting Apple's requirements.
    Oracle "strongly recommends" applying the CPU fixes as soon as possible, saying that the latest Critical Patch Update contains 50 new security fixes across all Jave SE products.
    Update foror Snow Leopard users:
    Apple have issued update 12 for Java for OS 10.6:
    http://support.apple.com/kb/DL1573
    Note:  On systems that have not already installed Java for Mac OS X 10.6 update 9 or later, this update will configure web browsers to not automatically run Java applets. Java applets may be re-enabled by clicking the region labeled "Inactive plug-in" on a web page. If no applets have been run for an extended period of time, the Java web plug-in will deactivate.

  • Help!Can't access iCloud (pics apps) even with correct password. Won't download my stored info on my new phone

    Help!Can't access iCloud (pics apps) even with correct password. Won't download my stored info on my new phone

    That happens because photo stream photos only remain in iCloud for 30 days, even though your last 1000 photo stream photos remain on your devices until deleted.  When you enabled photo stream on your iPod 4, you only received photo stream photos from the last 30 days as older photos are no longer in iCloud.  If you want to stream these older photos to your new iPod, you will have to create a shared photo stream on your old one that contains these photos (requires iOS 6 or higher) and invite yourself as a subscriber, as explained here: http://help.apple.com/icloud/#/mmc0cd7e99.

  • Help Needed in creating dropdown menu in excel using JXL

    Hi,
    I am trying to create dropdown menu in using JXL.
    The Code:
    private void createRequiredRows(WritableSheet writableSheet, List unallowCodeList,int rowCount
                   , int startRowNo,int colCount) throws WriteException {
    Label unallowCode = null;
              WritableFont noBoldFont = new WritableFont(WritableFont.ARIAL, 8,WritableFont.NO_BOLD);
              WritableCellFormat dropDownCellFormat = new WritableCellFormat(noBoldFont,new NumberFormat("000"));
              dropDownCellFormat.setAlignment(Alignment.RIGHT);
              WritableCellFeatures writableCellFeature = new WritableCellFeatures();
              writableCellFeature.setDataValidationList(unallowCodeList);
              for (int rowNo = startRowNo; rowNo < startRowNo + rowCount; rowNo++) {
                   unallowCode = new Label(colCount, rowNo, "Select",dropDownCellFormat);
                   unallowCode.setCellFeatures(writableCellFeature);
                   writableSheet.addCell(unallowCode);
    it creates a drop down in the Excel.
    But writableCellFeature.setDataValidationList(unallowCodeList); has a limitation of characters .So the dropdown menu gets truncated when it exceeds the limitation.
    Can anyone help me in creating dropdown menu in excel without any limitation using JXL..
    Thanks,
    Bisin

    Hi,
    I dont know the solution for this, but heres a work arround
    //create new label some where else in the excel sheet as shown below
    Label lblcmbdata;
    for(int i=0; i<1000; i++)
                 lblcmbdata = new Label(75, i, (i+1)+" satish", format);
                 sheet1.addCell(lblcmbdata);
    }//set the validation range as shown below
    writableCellFeature.setDataValidationRange(75,0,75,1000);
    Label cmb = null;
    cmb = new Label(0, 1, "Select",format);
    cmb.setCellFeatures(writableCellFeature);
    sheet.addCell(cmb);this will create a combo list with 1000 values
    also you can keep the data to be populated in the different sheet in same workbook by creating a named range as below
    workbook.addNameArea("cmbdata", sheet1, 0, 0, 0, 1000);
    // then fill the data in sheet1
    Label lblcmbdata;
    for(int i=0; i<1000; i++)
                    lblcmbdata = new Label(0, i, (i+1)+" satish", format);
                    sheet1.addCell(lblcmbdata);
    //set the validation named range as below
    writableCellFeature.setDataValidationRange("cmbdata");
    Label cmb = null;
    cmb = new Label(0, 1, "Select",format);
    cmb.setCellFeatures(writableCellFeature);
    sheet.addCell(cmb);Thanks and Regards
    Satish

  • [ETL]Could you please help with a problem accessing UML stereotype attributes ?

    Hi all,
    Could you please help with a problem accessing UML stereotype attributes and their values ?
    Here is the description :
    -I created a UML model with Papyrus tool and I applied MARTE profile to this UML model.
    -Then, I applied <<PaStep>> stereotype to an AcceptEventAction ( which is one of the element that I created in this model ), and set the extOpDemand property of the stereotype to 2.7 with Papyrus.
    -Now In the ETL file, I can find the stereotype property of extOpDemand as follows :
    s.attribute.selectOne(a|a.name="extOpDemand") , where s is a variable of type Stereotype.
    -However I can't access the value 2.7 of the extOpDemand attribute of the <<PaStep>> Stereotype. How do I do that ?
    Please help
    Thank you

    Hi Dimitris,
    Thank you , a minimal example is provided now.
    Version of the Epsilon that I am using is : ( Epsilon Core 1.2.0.201408251031 org.eclipse.epsilon.core.feature.feature.group Eclipse.org)
    Instructions for reproducing the problem :
    1-Run the uml2etl.etl transformation with the supplied launch configuration.
    2-Open lqn.model.
    There are two folders inside MinimalExample folder, the one which is called MinimalExample has 4 files, model.uml , lqn.model, uml2lqn.etl and MinimalExampleTransformation.launch.
    The other folder which is LQN has four files. (.project),LQN.emf,LQN.ecore and untitled.model which is an example model conforming to the LQN metamodel to see how the model looks like.
    Thank you
    Mana

Maybe you are looking for

  • Help JDeveloper cannot find package

    Hi, I am using JDeveloper 9.0.3.4. In the project settings -->Configurations -->Development --> Libraries, I add JSP Runtime, J2EE, Servlet Runtime. But When I tried to rebuild my project, I got errors like: (1) package javax.servlet.jsp does not exi

  • How to create PDF from Crystal Report instead of CRT

    Hi How can we view the reports as PDF within SAP Portal (instead of viewing crt-Files with BO-iView-template)? I know CRs as PDF from SAP NW IdM - reports are created as PDF there. We use CR 2008 SP2 with SAP_BW as datasource. We'd like to view the r

  • Encore CS4 Suddenly Won't Open

    I use Encore CS4 everyday. I just used it to render & burn a DVD and it worked perfectly. I closed Encore and tried to reopen it but it crashed. After a few seconds I got the Crash Report window saying that Encore has unexpectedly quit. I rebooted th

  • Error: archive wine-0.9.11-1.pkg.tar.gz is corrupted

    I'm getting this when I try to upgrade wine. Anyone else?

  • Allow duplicate key & value in collection

    Hello Experts, I have once scenario where I have to store duplicate keys (string) and values (string) in Map. I tried with MultiHashMap (Apache) but it's very specific to datatype. It will only allow "string" key and "integer" value. How can I do it?