Accessing ms access database

i want to create a table in ms access, name of the table wud be given by the user.<br> i created a jsp page that takes name of the table from a html form page. i send it to a class file called CreateTbl.class thru the useBean. using setProperty() i assign the name. but seem to have trouble while accessing the database.
once the exception occured during loading the DriverManager and other times during the Statement object creation.
i am including the codes of the jsp and the bean for convinence<br>
package project;
import java.sql.*;
import java.io.*;
public class CreateTbl
     private String tblname="anyname";
     private int flag;
     public String getTblname()
           return(tblname);
     public void setTblname(String tblname)
          this.tblname=tblname;
     public int getFlag()
          return flag;
     public void tblCreation()
          Connection conn;
          String crt_cmd;
          Statement stm;
          crt_cmd="create table " +tblname+"(Rdate date,paddy real,g_nut real)";     
          try{     
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          catch(ClassNotFoundException cnf){
               //flag="forName excep"+cnf;
               flag=0;
               //return flag;
          try{     
               conn=DriverManager.getConnection("jdbc:odbc:acses");
// acses is the dsn
               stm=conn.createStatement();
               stm.executeUpdate(crt_cmd);
               flag=1;
               //flag="Table Created successfully";
               //System.out.println("table created successfully");
               stm.close();
               conn.close();
          catch(SQLException sqlexcep){
               //System.out.println("sql excep: "+sqlexcep);
               flag=2;
               //flag="excep" + sqlexcep;
               //return flag;// return 'false' if table cud not be created
[\code]
This is the jsp page<%@ page language="java" %>
<%! String tblnm; %>
<%     tblnm = request.getParameter("tbl_name"); %>
<jsp:useBean id="crtnew" class="project.CreateTbl"/>
<jsp:setProperty name="crtnew" property="tblname" value="<%= tblnm %>"/>     
<jsp:getProperty name="crtnew" property="tblname" />
<html>
<head>
     <title>Table Creation</title>
</head>
<body>
<%     crtnew.tblCreation(); %>
<jsp:getProperty name="crtnew" property="flag" />
<% if (crtnew.getFlag()==1) { %>
Congratulations! You got it.
<% } else if (crtnew.getFlag()==0) { %>
<b>cnf error
Try again with a new name
<% } else { %>
<B>Error: Table cud not be created sqlexcep</B>
Try again with a new name
<% } %>
</body>
</html>
[\code]

i want to create a table in ms access, name of the table wud be given by the user.
i created a jsp page that takes name of the table from a html form page. i send it to a class file called CreateTbl.class thru the useBean. using setProperty() i assign the name. but seem to have trouble while accessing the database.
once the exception occured during loading the DriverManager and other times during the Statement object creation.
i am including the codes of the jsp and the bean for convinence
javabean
package project;
import java.sql.*;
import java.io.*;
public class CreateTbl
     private String tblname="anyname";
     private int flag;
     public String getTblname()
           return(tblname);
     public void setTblname(String tblname)
          this.tblname=tblname;
     public int getFlag()
          return flag;
     public void tblCreation()
          Connection conn;
          String crt_cmd;
          Statement stm;
          crt_cmd="create table " +tblname+"(Rdate date,paddy real,g_nut real)";     
          try{     
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          catch(ClassNotFoundException cnf){
               //flag="forName excep"+cnf;
               flag=0;
               //return flag;
          try{     
               conn=DriverManager.getConnection("jdbc:odbc:acses");
               stm=conn.createStatement();
               stm.executeUpdate(crt_cmd);
               flag=1;
               //flag="Table Created successfully";
               //System.out.println("table created successfully");
               stm.close();
               conn.close();
          catch(SQLException sqlexcep){
               //System.out.println("sql excep: "+sqlexcep);
               flag=2;
               //flag="excep" + sqlexcep;
               //return flag;// return 'false' if table cud not be created
}the jsp file
<%@ page language="java" %>
<%! String tblnm; %>
<%     tblnm = request.getParameter("tbl_name"); %>
<jsp:useBean id="crtnew" class="project.CreateTbl"/>
<jsp:setProperty name="crtnew" property="tblname" value="<%= tblnm %>"/>     
<jsp:getProperty name="crtnew" property="tblname" />
<html>
<head>
     <title>Table Creation</title>
</head>
<body>
<%     crtnew.tblCreation(); %>
<jsp:getProperty name="crtnew" property="flag" />
<% if (crtnew.getFlag()==1) { %>
  Congratulations!  You got it.
<% } else if (crtnew.getFlag()==0) { %>
  <b>cnf error
<a href="NewTbl.jsp">Try again with a new name</a>
<% } else { %>
  <B>Error: Table cud not be created sqlexcep</B>
  <a href="NewTbl.jsp">Try again with a new name</a>
<% } %>
</body>
</html>

Similar Messages

  • Connect to a remote MS Access database using RmiJdbc

    Hello,
    I want to access a remote MS Access database from oracle stored procedures.
    Does anyone know how i can load the RmiJdbc driver using the loadjava command or with any other way.
    Because when i try to load RmiJdbc.zip using the loadjava command I am getting the error:
    ORA-29533:attempt to overwrite class or resource string while defining or compiling scott.TestClient
    this error is occured for multiple files...
    I don't know how to delete this classes.
    Because this error occured and the first time i tried to load Rmijdbc driver.
    and when i use the dropjava command to drop it,and then load it again the same error occures.
    Can anyone help me how to load this driver?
    Please answer because i need it as soon as possible.
    Thanks

    Hi,
    try this.
    String s = "UPDATE AGENT SET afname='test',alname='u',city='d',AGENT.[percent]=1 WHERE aid=23";
    -------->AGENT.[percent]

  • How to Protect your Custom Access Database Product - so that you can sell & distribute it?

    I'm looking for an update on this topic as I have been away from Access for a couple of years and have not kept up with the latest.
    Hopefully they have made it easier to design, develop, sell and distribute custom database solutions. So here goes...
    Question A:
    If one develops a custom database product with Access 2013 what is the current best way to...
    1 - Prevent it from being (too easily) copied
    2 - Prevent it from being (too easily) reverse engineered
    3 - Prividing a time limited free demo copy?
    4 - Providing a demo copy with limited functionality... like limiting the number of records in an important table, or whatever?
    5 - What have I left out of this list that should be considered for protecting ones investment in the development of the product? (other than copyright, of course.)
    Question B:
    What is the latest on being able to migrate an Access database to the cloud?
    1 - Entirely online
    2 - Part in the cloud and part on the users machine
    3 - And what about all that VBA code - is there no way to make that work in the cloud and/or on a web server... or does it all have to be tossed and all the coding redone?
    Question C:
    What are other alternatives solutions for selling your custom database application while protecting all your investment in developing it?
    1 - Write the front end in C++  (so that it is fully compiled) and the back end in ASP with MS SQL Server? (or alternative server side solutions)
    2 - Write the whole thing as a server side solution with browser interface?
    3 - Or what?
    Thanks for any help.

    Hi Fran_3,
    >>What is the latest on being able to migrate an Access database to the cloud?
    In my option, the Access Web app would be a better choise.
    Regards,
    Tony
    Help each other

  • "Connection is closed" closed error while using MS Access database

    We are using MS Access database in our project. Recently the database was upgraded to 2000.
    After upgrading the database, I get the folowing error when getAutoCommit() is called on a connection -
    java.sql.SQLException: Connection is closed
         at sun.jdbc.odbc.JdbcOdbcConnection.validateConnection(Unknown Source)
         at sun.jdbc.odbc.JdbcOdbcConnection.getAutoCommit(Unknown Source)
    The connection is not closed explicity before getAutoCommit() is called, only the statement is closed.
    This error is sporadic and occurs under load scenario only (when a lot of connections are open). Once the error occurs, all the database calls fail then onwards. The error was not occuring before the database was upgraded.
    I suspect the jbdc-odbc driver. The driver might not be compatible with Access2000 database. Under load scenario, it might be closing connections automatically.
    Has anybody faced similar problem before? Where can I find the compatible jdbc-odbc driver? And how to ensure that it is jdbc-odbc driver problem only?
    The database verison - MS Access 2000
    Java version - 1.3.1_01

    can i just point out that there is no support for transactions in Access so I wonder why you are calling autoCommit methods at all...

  • Access of ms access database and displaying it on applets

    I had made the connection thru JDBC and was able to access data from MS Access database when i had written java application program. But when i created one applet and created instance of that class which was making connection to the database thru JDBC and called one method which was returning one value from the database , i was not able to get on the applet(in the text field) . It gave me some security exception saying acces is not allowed.
    Please give me the reason for this and send me reply back on this email id
    [email protected]

    Welcome to the club. There is an on-going discussion from which I too would like to learn this. Try http://forum.java.sun.com/thread.jsp?forum=31&thread=174953.
    Best Wishes.

  • Not getting the records from Access database

    Hi All,
    Iam creating a universe based on Access database. I am able to view the data from all the tables except one table. When i try to view the data there is one error message "Syntax error in from clause, State: 37000". Everything is ok at database side. What does this error means?
    Please help me on this.
    Thanks.

    Hi BOCP,
           Thanks for your reply. I have resolved my issue. Actually my issue was, I have a table "Date" in universe which was created in Access database, when i tried to view the Date Table values in Universe i was getting that Syntax error in From clause message. I came to know that Date is a keyword or predefined table in WebI & it wont accept that word as a user defined Table. So i renamed that table in Access and Universe. Now my issue was solved.
    Thanks,
    Swati.

  • Refreshing Excel 2010 workbook with connection to Access database on shared network drive

    I have an Excel 2010 workbook that has a connection to an Access database that's on a shared drive on the company network. I can refresh the data in the regular Excel application but when it's hosted in the browser I get this error message "The data
    connection uses Windows Authentication and user credentials could not be delegated."
    Next, I installed PowerPivot for SQL server 2008 and used PowerPivot to connect to the same Access database. I uploaded it to a PowerPivot gallery but when I try to refresh the data but it says "the workbook was created in an older version of Excel
    and PowerPivot and cannot be refreshed until the file is upgraded." I tried to go to "Manage data refresh" but I get the "Sorry, something went wrong" page. Do I need to install PowerPivot for SQL server 2012 to do scheduled data refreshes?
    What about manual refreshes?

    I have an Excel 2010 workbook that has a connection to an Access database that's on a shared drive on the company network. I can refresh the data in the regular Excel application but when it's hosted in the browser I get this error message "The data
    connection uses Windows Authentication and user credentials could not be delegated."
    Next, I installed PowerPivot for SQL server 2008 and used PowerPivot to connect to the same Access database. I uploaded it to a PowerPivot gallery but when I try to refresh the data but it says "the workbook was created in an older version of Excel
    and PowerPivot and cannot be refreshed until the file is upgraded." I tried to go to "Manage data refresh" but I get the "Sorry, something went wrong" page. Do I need to install PowerPivot for SQL server 2012 to do scheduled data refreshes?
    What about manual refreshes?

  • Unable to Publish Access database to SharePoint site in 2013

    I have a user requesting to publish access (2007/2010) web database into SharePoint 2013. I am able to publish this database on all sites under one site collection (test) but fails on the other site (different site collection). I have compared site collection
    and site features and both site collection (working and non-working one) has SharePoint Server Enterprise Site features enabled. Is there any other features that should be turned on? 
    Initially it looks it has succeded but then give mesesage
    "Publish Failed - Your application has encountered errors while attempting to publish. The publish operation has failed and the target site has not been created. For more details, see the following tables
    Moveto SharePoint Site Issues"
    Move to SharePoint Site Issues
    Issue
    Reason
    Object Type
    Object Name
    Field Name
    There was an error uploading properties and/or data macros on this table.
    Table
    mytab
    Errors have prevented one or more tables from being uploaded to the server.
    Table
    Could not save this object's changes to the server. You must enter a value in the 'Name' field.
    Navigation Pane
    Navigation Pane
    Could not save this object's changes to the server. You must enter a value in the 'Name' field.
    VBA Properties
    VBA References
    Could not save this object's changes to the server. You must enter a value in the 'Name' field.
    Database Properties
    DBProps
    Could not save this object's changes to the server. You must enter a value in the 'Name' field.
    Theme
    Office Theme
    <tfoot></tfoot>
    I am unable to make any sense as it's one empty table and able to publish same table on another site (under different site collection). 
    MK Sin

    Hi MK,
    According to your description, my understanding is that you got an error when you published Access database to SharePoint 2013.
    Please deactivate SharePoint Server Enterprise Site Collection features at site collection level and deactivate SharePoint Server Enterprise Site features at site level, then activate them again, compare the result.
    Per the error message, please type a value in the ‘Name’ filed, then publish the table, compare the result.
    In addition, here is a similar article, please check whether it is useful for you:
    http://support.microsoft.com/kb/2711562
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • DW Procedures to connect to MS ACCESS database located on remote server

    I am confused about the procedures within Dreamweaver CS3 to connect to a MS ACCESS database on a remoter server.
    I am working through a tutorial book, "Dreamweaver 8 with ASP, Cold Fusion and PHP Training from the Source", but the instructions are unclear concerning the procedures to connect to a MS ACCESS database located on a remote server. 
    The book indicates that the server administration has to create the DSN for you and screen shots indicate that you will result in a list of DSNs to choose from when creating the connections .asp file.
    I went through the procedures to create a connections .asp and resulting in a connection without and tables (of course) because I do not initially have any connection information from my remote site.
    I have generated the required two lines of code as follows for my MS ACCESS database connection on my remote server:
    'Database connection info and provider
    strCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&_
    Server.MapPath("database\trans.mdb") & ";" &_
    "User ID=xxx;Password=xxxxx"
    The question that I have is:
    How does this connection coding relate to the "connections/conn_newland.asp" file that was create within the Dreamweaver screens?  How do I merge the ASP coding?  The file (/connections/conn_newland.asp) generated within Dreamweaver is as follows:
    <%
    'FileName="Connection_odbc_conn_dsn.htm"
    'Type="ADO"
    'DesignationType="ADO"
    'HTTP="true"
    'Catelog=" "
    'Schema
    Dim MM_conn_newland_STRING
    MM_conn_newland_STRINT = "dsn=newland;"
    %>
    Any advice would be appreciated.  I know that this is simple but debugging an error from an  ASP coding merge would be a "bear" to debug!

    I have not used MS Access myself (fortunately) but I believe it works much like the old, old way of achieving a multi-user database in FileMaker.
    That is, it is not a true client-server database but more a peer-to-peer database and that each peer opens the same database file which is available to multiple user via file sharing. Therefore as elikness said it should just be a matter of putting the files on your Lion Server and then sharing that folder/volume using SMB sharing.
    However one thing to be aware of, since MS Access is not a true client-server database I would imagine it uses record locking to manage simultaneous direct access to records in the same files. File or Record locking is something that has historically been a bit flakey when using Windows clients with a Mac file server (and probably vice versa).
    While I am not proposing it as a solution to consider seriously, it is worth you knowing that FileMaker Pro is a database system that is available for both Mac and Windows and depending on how you configure things can be considered to stretch from a configuration very similar to MS Access at the low end all the way to a high-end MS SQL Server style setup at the top end. See http://www.filemaker.com for details.
    There is also a a third-party tool available for migrating databases to or from FileMaker Pro and it can convert MS Access databases to FileMaker Pro see http://www.fmpromigrator.com/
    You could use FileMaker Pro just on Windows machines if you wish.

  • How to connect my access database using applet?

    hi all,
    i need to connect my access database in my applet program which should work like an atm machine..I dont know how to connect it. Im new to applet same thing in JDBC application. Please help i terribly need it, our deadline in our case study is fast approaching and i still dont know how to do it. I tried the tutorial but i received some sql exception error. thanks!

    Try this link
    http://java.sun.com/docs/books/tutorial/jdbc/basics/

  • How do I open a pdf stored in a Microsoft Access database using Visual Basic studios 2012

    Currently I am unable to find a valid method of being able to open a pdf stored in a Microsoft Access database using Visual Basic studios 2012. I've tried displaying the entire database on a form, but when I do this all the other columns show up with
    the correct data besides the one containing the pdf's, it just displays <binary data> in each row down the column. I also tried another method with which you use the database as a dataset and can drag and drop the rows and columns into the form, which
    again works for all the other columns besides the one containing the pdf's but this time I'm unable to interact with the column  at all. 
    Not too sure if this is in the correct place, but any answers or help would be appreciated. Cheers.

    Alex,
    This forum is dedicated to Project and Project Server. You might get better response, if you post to a Visual Basic forum. Here are couple I could find. 
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral%2Cvblanguage&filter=alltypes&sort=lastpostdesc
    Cheers,
    Prasanna Adavi, Project MVP
    Blog:
      Podcast:
       Twitter:   
    LinkedIn:
      

  • The Microsoft Access database engine cannot open or write to the file in Report Builder 3.0

    I am trying to build a report in Report Builder 3.0.  I created the Data Source to point to my Excel file and the Data Set.  I drag a couple of fields on to the canvas and then choose Run.  I get the error:  "The Microsoft Access
    database engine cannot open or write to the file.  It is already opened exclusively by another user".  I am using the Excel driver.  Why am I getting this message?  How can I fix this?

    No, now I am getting the error message again.  It is quite long:
    ERROR [HY000] [Microsoft][ODBC Excel Driver] The Microsoft Access database engine cannot open or write to the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view and write its data.
    ERROR [01S00] [Microsoft][ODBC Excel Driver]Invalid connection string attribute Trusted_Connection
    Please help

  • Open an Access database from ASP on the Windows 2008 32-bit server

    We are upgrading to a Windows 2008 server.  The ASP application opens an Access database with this code:
      Set oConn=Server.CreateObject("ADODB.connection")
      oConn.Open  "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=E:\webdata\applications\po\sfisnet\sfisnet.mdb;"
    The open statement causes this error:
           Number: -2147217887
           Description: Multiple-step OLE DB operation generated errors. Check each OLE DB
           status value, if available. No work was done.
           Source: Microsoft JET Database Engine
           SQL State:
           Native Error: 0
    Research includes: 
     - ODBC drivers  
     - verified that the ms jet dll is present: msjet40.dll, msjet35.dll
     - IIS settings reviewed
     - permission and sharing on the directory and "sfisnet.mdb" database
     - verifies thet OLEDB_SERVICES is in the registry

    They'll help you over here.
    Microsoft ASP.Net forums
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • SQL Query with MS-Access Database

    Hi,
    I have linked my oracle database with MS-Access via a DB LINK. i can access the data from MS-ACCESS, but i have a problem that when i specify the column name or define a where clause in my query it gives me the error ORA-00904: invalid identfier ..
    This query fetch the data without any problem SELECT * FROM TBLREPORT@M_ACCESS but when i run SELECT EMP_ID FROM TBLREPORT@M_ACCESS it gives me the error i mentioned above. (Column name have No problem or mistake of spelling even CASE)
    also when i try to put where clause in the query it gives me same error SELECT * FROM TBLREPORT@M_ACCESS WHERE EMP_ID = '100' (Error)
    is there any change in SQL query for ACCESS database ??
    any clue
    Regards
    Rehman

    Are column/table names in access case sensitive? Issue
    DESC TBLREPORT@M_ACCESS If column EMP_ID actual name shows up in mixed/lower case, enclose it in double quotes and use the exact case. E.g., if column name shows up as Emp_Id, use:
    SELECT "Emp_Id" FROM TBLREPORT@M_ACCESSSY.

  • How to automate creation of MS Access databases/tables/records

    Can someone point me to some examples that automate the creation of MSAccess database files and tables?
    Can I do this with a bat file? If not, a ps1 file?
    I bing searched and could not find an example.
    I want to test the existence of a mdb (or accdb) file and if it does not exist, create it.
    Then I want to see if that mdb (or accdb) file contains a table named "parts".
    If it does not contain that table named "parts", create the table.
    If that table does not contain any records, than add some sample data, presumably with some SQL "INSERT" statements.
    What is the preferred API for this? I was thinking we should use the ADO.NET/OleDB API. I did find a few examples of queries of MSAccess databases with the old ADO API.
    ADOX seems very old for creating databases. Is there any thing more modern?
    Is powershell the easiest scripting language to do this?
    Thanks
    Siegfried
    siegfried heintze

    This blog post should have most (if not all) of what you need:
    http://blogs.technet.com/b/heyscriptingguy/archive/2009/02/16/how-can-i-use-windows-powershell-to-create-an-office-access-database.aspx
    One thing to watch out for is the db provider for the connection string.  The "Jet Engine" has been superseded by
    ACE.

  • How To Insert Data into a Access Database from a PDF File

    Hi All,
    Could anyone help me to insert PDF form data to an MS Access database.I am new to this and I would appreciate if anyone can help me at the earliest.
    Thanks,
    Deepti

    You can submit your PDF to a server-side script (ASP/PHP), and store the new record in a MS Access database.
    For more information on how to store your PDF submission in a database, please visit:
    http://www.fdftoolkit.net

Maybe you are looking for