How to create a ms-access database at runtime using java
hi, this is ravi kiran,
i have a situation where i need to create a new ms-access database with one table in it at runtime(when user clicks on some button).
i have been searching many sites to know how to do this in java, but i didnot find any thing useful.
plz tell me how to do this in java.
plz help me, its urgent
thanx in advance.
Here's how I did it. Research does help, but sometimes looking at others code does too... You do have to have a dummy file that you made with access though. You can't just make a file file.mdb (it will be corrupt)
public void createDatabase(String database) throws SQLException{
try{
// This file needs to have been created with MS Access
File dbfile = new File(this.dataBaseDir + "dummy.mdb");
// This is the new database file being made
File newFile = new File(this.dataBaseDir + database + ".mdb");
// Copy all bytes from dummy file to new DB file.
FileInputStream instream = new FileInputStream(dbfile);
FileOutputStream ostream = new FileOutputStream(newFile);
int numBytes = instream.available();
byte inBytes[] = new byte[numBytes];
instream.read(inBytes, 0, numBytes);
ostream.write(inBytes, 0, numBytes);
catch(FileNotFoundException e) { e.printStackTrace();}
catch(IOException e) { e.printStackTrace();}
if(DEBUG) System.out.println("creating the " + database + " database");
}
Similar Messages
-
Creating a new access database using JDBC
Hi Forum,
I have a problem in hand. Let me describe the problem:
I want to create an "access database" from java at runtime. "Access database" is file based, so for a database named test, it will have a file test.mdb.
Now, everything's sweet and wonderful, if somebody creates an "empty access database" at the client machine and i then connect to it and create the tables i require.
But the issue is i want to create the database at runtime (the database name and tables are determined at runtime).
Using the JDBC:ODBC bridge driver , i am able to connect to an existing database, but any "create database" statements are not supported.
A last ditch solution would be that i create an empty database using access and copy the file contents in the SQL server database as a a blob object. Then when i want to create a new access database at runtime, i create a file in a particular folder , with an .mdb
extension, copy the file contents from the SQL server (i also have an SQL server connection) BLOB object, and then try to connect to the
.mdb file.
But this approach seems a "quick hack" and can have problems (which i can't see as of now).
Can you suggest a better alternative for the problem.
See the Java Sun forum at this address for a discussion of a similar problem, but sadly with no solution.
http://forum.java.sun.com/thread.jspa?forumID=31&threadID=484731I have an applet that was previously connected to Oracle 9i. I am faced with connecting to MS Access temporarily for testing purposes.
I have been unable to successfully code connection in java. I have set up the DSN and can access in SQL Worksheet in JDev.
I saw your question regarding creating an access db, and thought you might be so kind as to help me code the connection to access!!!!
Any help you could provide would be greatly appreciated. I have a huge application to finish with alot of sqlj already completed. Connectivity is not my area of expertise!
Any help you could provide would be greatly appreciated!!!
I am not sure if I have to use bridge? Am I progressing in right direction to migrating to SQL Server if need be? -
Can i create a ms-access database (very urgent)
hi folks
i really need help in creating a ms-access database, i searched the forums but i couldnot find any answers.
i really appreciate if anyone can tell how to create a ms-access databasehi folks
i really need help in creating a ms-access database, i
searched the forums but i couldnot find any answers.
i really appreciate if anyone can tell how to create a
ms-access databaseIn java, the actual mdb file? You can't.
The best you can do is create an empty mdb file and copy each time you need to create a new one. -
How to create a sql server database in SQL DEVELOPER.
I installed the SQL DEVELOPER 1.5.5, but i can't found where to create the sql server database in it. please kindly tell me if you feel free.
Thanks so much in advance.Hi,
Take a look at the main [ SQL Developer page on OTN|http://www.oracle.com/technology/products/database/sql_developer/index.html]. There is a link you should find useful, it's the Getting Started link under the Migration section. This explains how to download and setup the drivers you need to correct to non-Oracle databases. There are also links to online demonstrations on how to create connections to these databases. See how you go with that material.
It should help.
Sue -
How to create a model access class ???
HI,
Can somebody tell me how to create a Model Access Class. In the Application Set, i can find the Model Access folder, but it has a list of application sets which is already created and the system asks to select a Application set. I need to create a new application set. Please help.
Regards,
ShinyHi Shiny,
I would suggest you not to create a new application set.
If you are enhancing a standard PCUI application, i would suggest you to create new model access classes and assign them to the same application set which is assigned with the standard model access class for that application.
Creating a model access class can be done through the transaction SE24(like any other Z-class).
Go to transaction CRMC_BLUEPRINT_C and you could assign this newly created Model access class to the standard application set. This can be done under Application Element->Application Set->MOdel Access Class.
If you still feel the need to create a new application set altogether, it can be done from Trx CRMC_BLUEPRINT_C->Layout of PCUI-> Application Element->Application set.
I hope it helps.
Cheers,
Gyan. -
How do i connect ms access database in Eclipse ?
Help me to solve the problem
how do i connect ms access database in Eclipse ?
Its urgent please
give any link that gives the procedure to connect ...........The Eclipse WTP by default has a database explorer: Window - Show View - Data. Finally rightclicking at the new "DB Servers" console gives straightforward menu options.
-
How to view corrupt ms access database?
How to view corrupt ms access database? When you open a written "Application Error" and all. Tried to import objects into a
new database. Tables and queries were imported without a problem, but on the forms, reports and modules gives the same error.if it fails to recover all known methods, which are described in google, then you need software - such as MDB Viewer Tool from http://www.mdb.viewertool.com/ Somewhere
seen a similar problem on the forum if it fails to recover all known methods, which are described in google, then you need software - such asMDB Viewer Tool from http://www.mdb.viewertool.com/Somewhere
seen a similar problem on the forumhttp://www.filerepairforum.com/forum/microsoft/microsoft-aa/access/1318-unable-to-open-mdb-file-please-help -
How to create secondry index on database table
how to create secondry index on database table
Hi
By trx SE11:
- Choose your table and press CHANGE ICON, so INDEX
When you create an index you should consider if your index is contained in another index.
If the fields of your index are:
- FIELD1, FLIED2, FIELD3
...it'll be triggered only if the select is:
SELECT * FROM <TABLE> WHERE FIELD1
AND FIELD2
AND FIELD3
A select like this
SELECT * FROM <TABLE> WHERE FIELD1
AND FIELD3
AND FIELD2
doesn't use your index.
Max -
Deleting a MS Access database table record using JOptionPane
hi!
just want some help here..
is there a way to delete a MS Access database record through using JOptionPane?? i've gone through some, probably alot of examples on SELECT, INSERT, UPDATE, DELETE statements but none came up to the stuff i need.
so far i've seen the DELETE statement like this and also this is a common DELETE statement..
statement.executeUpdate("DELETE FROM tableName WHERE fieldName01 = 'blablabla' AND fieldName02 = 'etcetcetc'");like INSERT, there's a coding somewhat like this:
String asd = JOptionPane.showInputDialog(null, "Enter blablabla stuff");
statement.executeUpdate("INSERT INTO whatEverTableName (tableFieldName) VALUES('"+asd.getText()+"')");so, is it possible using the same method for DELETE??
help and advices are appreciated in advanced..Here's how I did it. Research does help, but sometimes looking at others code does too... You do have to have a dummy file that you made with access though. You can't just make a file file.mdb (it will be corrupt)
public void createDatabase(String database) throws SQLException{
try{
// This file needs to have been created with MS Access
File dbfile = new File(this.dataBaseDir + "dummy.mdb");
// This is the new database file being made
File newFile = new File(this.dataBaseDir + database + ".mdb");
// Copy all bytes from dummy file to new DB file.
FileInputStream instream = new FileInputStream(dbfile);
FileOutputStream ostream = new FileOutputStream(newFile);
int numBytes = instream.available();
byte inBytes[] = new byte[numBytes];
instream.read(inBytes, 0, numBytes);
ostream.write(inBytes, 0, numBytes);
catch(FileNotFoundException e) { e.printStackTrace();}
catch(IOException e) { e.printStackTrace();}
if(DEBUG) System.out.println("creating the " + database + " database");
} -
How to create the log file in remote system using log4j.
Hi,
How to create the log file in remote system using log4j. please give me a sample code or related links.The below example i used for create the log file in remote system but it return the below exception.Is there any authandication parameter for accessing the remote path? Please help.
public class Logging
Logger log=null;
FileAppender fileapp=null;
public Logging(String classname)
try
log = Logger.getLogger(classname);
String path=" [\\192.168.0.14\\c$\\LOG\\d9\\May_08_2008_log.txt|file://\\192.168.0.14\\c$\\LOG\\d9\\May_08_2008_log.txt]";
fileapp = new FileAppender(new PatternLayout("%r [%t] %-5p %c %x - %m%n"),path, true);
log.addAppender(fileapp);
log.info("Logger initilized");
}catch(Exception ex)
ex.printStackTrace();
java.io.FileNotFoundException: \\192.168.0.14\c$\LOG\d9\May_08_2008_log.txt (The network path was not found)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
at org.apache.log4j.FileAppender.<init>(FileAppender.java:109)
at annwyn.logger.BioCapLogger.<init>(Logging.java:23)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Please help.
Thanks in advance.
Saravanan.KSorry path is missing for the above request.
path="\\192.168.0.14\c$\LOG\d9\May_08_2008_log.txt ";
please help.
Saravanan.K -
How to create multiple component instances at runtime using java
Hi,
I need to create component instances at runtime using java.I found ComponentSet.add method.But I am not finding a way to get handle of ComponentSet.
I see methods with params of IRuntimeNode.But how to get ComponentSet from IRuntimeNode.
If anybody knows or have sampel code then please share with me.
thanks,
ashokAshok --
This is a common challenge for those using Configurator Extensions with multiple instantiation for the first time. The problem is that the CIO's representation of the structure for multiply-instantiable Components differs slightly from what both Configurator Developer users and Configurator Runtime users see in those respective applications. Multiply-instantiable Components are not direct children of the Model in which they're defined. Internally, there is an entity that sits between the parent Model and the instantiable Components; that intermediate entity is the ComponentSet object you've found in the CIO documentation.
If the name of your multiply-instantiable Component is "My Component", then its ComponentSet may be accessed simply by calling getChildByName("My Component") on its parent Model; a List of the instantiated Components may be accessed with the ComponentSet's getChildComponentNodes() method, and instances may be added and deleted using its add() and delete() methods.
Hope this helps.
Eogan -
How to Create an Input Schedule Comparison with Data Using EVDRE
Hello,
I try implement the scenario described in "How to Create an Input Schedule Comparison with Data Using EVDRE".
Once I am using the "Insert Function" from the panel and selecting the EVTIM function Excel crashes (see page 8 How to paper).
Systems:
BPC 7.0 NW SP02
Office 2007
BPCADminClient and BPCOfficeClient up to date
Have anyone a solution?
Thanks
OktayHi Oktay -
This function works in my BPC70NW SP02 system. Your issue might be that you are trying to access a TIME member that does not exist. Please make sure the offset value is a valid dimension member.
I can confirm that EVTIM does allow the offset for base members (such as 2009.MAY) as well as parent nodes (such as 2009.Q1 or 2008.TOTAL)... BUT...the offset result of the EVTIM function needs to be a valid dimension member!
Regards,
Sheldon -
How to create a node with attributes at runtime in webdynpro for ABAP?
Hi Experts,
How to create a node with attributes at runtime in webdynpro for ABAP? What classes or interfaces I should use? Please provide some sample code.
I have checked IF_WD_CONTEXT_NODE_INFO and there is ADD_NEW_CHILD_NODE method. But this is not creating any node. I this this creates only a "node info" object.
I even check IF_WD_CONTEXT_NODE but i could not find any method that creates a node with attribute.
Please help!
Thanks
GopalHi
I am getting the following error while creating a dynamic context node with 2 attributes. Please help me resolve this problem.
Note
The following error text was processed in the system PET : Line types of an internal table and a work area not compatible.
The error occurred on the application server FMSAP995_PET_02 and in the work process 0 .
The termination type was: RABAX_STATE
The ABAP call stack was:
Method: IF_WD_CONTEXT_NODE~GET_STATIC_ATTRIBUTES_TABLE of program CL_WDR_CONTEXT_NODE_VAL=======CP
Method: GET_REF_TO_TABLE of program CL_SALV_WD_DATA_TABLE=========CP
Method: EXECUTE of program CL_SALV_WD_SERVICE_MANAGER====CP
Method: APPLY_SERVICES of program CL_SALV_BS_RESULT_DATA_TABLE==CP
Method: REFRESH of program CL_SALV_BS_RESULT_DATA_TABLE==CP
Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE_DATA of program CL_SALV_WD_C_TABLE_V_TABLE====CP
Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
Method: IF_SALV_WD_COMP_TABLE_DATA~UPDATE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
Method: IF_SALV_WD_VIEW~MODIFY of program CL_SALV_WD_C_TABLE_V_TABLE====CP
Method: IF_SALV_WD_COMPONENT~VIEW_MODIFY of program CL_SALV_WD_A_COMPONENT========CP
My code is like the following:
TYPES: BEGIN OF t_type,
CARRID TYPE sflight-carrid,
CONNID TYPE sflight-connid,
END OF t_type.
Data: i_struc type table of t_type,
dyn_node type ref to if_wd_context_node,
rootnode_info type ref to if_wd_context_node_info,
i_node_att type wdr_context_attr_info_map,
wa_node_att type line of wdr_context_attr_info_map.
wa_node_att-name = 'CARRID'.
wa_node_att-TYPE_NAME = 'SFLIGHT-CARRID'.
insert wa_node_att into table i_node_att.
wa_node_att-name = 'CONNID'.
wa_node_att-TYPE_NAME = 'SFLIGHT-CONNID'.
insert wa_node_att into table i_node_att.
clear i_struc. refresh i_struc.
select carrid connid into corresponding fields of table i_struc from sflight where carrid = 'AA'.
rootnode_info = wd_context->get_node_info( ).
rootnode_info->add_new_child_node( name = 'DYNFLIGHT'
attributes = i_node_att
is_multiple = abap_true ).
dyn_node = wd_context->get_child_node( 'DYNFLIGHT' ).
dyn_node->bind_table( i_struc ).
l_ref_interfacecontroller->set_data( dyn_node ).
I am trying to create a new node. That is
CONTEXT
- DYNFLIGHT
CARRID
CONNID
As you see above I am trying to create 'DYNFLIGHT' along with the 2 attributes which are inside this node. The structure of the node that is, no.of attributes may vary based on some condition. Thats why I am trying to create a node dynamically.
Also I cannot define the structure in the ABAP dictionary because it changes based on condition
Message was edited by: gopalkrishna baliga -
Hi,
The requirement is to create ""Document Sets in Bulk" using JSOM. I am using the following posts:-
http://blogs.msdn.com/b/mittals/archive/2013/04/03/how-to-create-a-document-set-in-sharepoint-2013-using-javascript-client-side-object-model-jsom.aspx
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/1904cddb-850c-4425-8205-998bfaad07d7/create-document-set-using-ecma-script
But, when I am executing the code, I am getting error "Cannot read property 'DocumentSet' of undefined "..Please find
below my code. I am using Content editor web part and attached my JS file with that :-
<div>
<label>Enter the DocumentSet Name <input type="text" id="txtGetDocumentSetName" name="DocumentSetname"/> </label> </br>
<input type="button" id="btncreate" name="bcreateDocumentSet" value="Create Document Set" onclick="javascript:CreateDocumentSet()"/>
</div>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"> </script>
<script type="text/javascript">
SP.SOD.executeFunc('sp.js','SP.ClientContext','SP.DocumentSet','SP.DocumentManagement.js',CreateDocumentSet);
// This function is called on click of the “Create Document Set” button.
var ctx;
var parentFolder;
var newDocSetName;
var docsetContentType;
function CreateDocumentSet() {
alert("In ClientContext");
var ctx = SP.ClientContext.get_current();
newDocSetName = $('#txtGetDocumentSetName').val();
var docSetContentTypeID = "0x0120D520";
alert("docSetContentTypeID:=" + docSetContentTypeID);
var web = ctx.get_web();
var list = web.get_lists().getByTitle('Current Documents');
ctx.load(list);
alert("List Loaded !!");
parentFolder = list.get_rootFolder();
ctx.load(parentFolder);
docsetContentType = web.get_contentTypes().getById(docSetContentTypeID);
ctx.load(docsetContentType);
alert("docsetContentType Loaded !!");
ctx.executeQueryAsync(onRequestSuccess, onRequestFail);
function onRequestSuccess() {
alert("In Success");
SP.DocumentSet.DocumentSet.create(ctx, parentFolder, newDocSetName, docsetContentType.get_id());
alert('Document Set creation successful');
// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
alert("Document Set creation failed" + + args.get_message());
Please help !!
Vipul JainHello,
I have already tried your solution, however in that case I get the error - "UncaughtSys.ArgumentNullException: Sys.ArgumentNullException:
Value cannot be null.Parameter name: context"...
Also, I tried removing SP.SOD.executeFunc
from my code, but no success :(
Kindly suggest !!!
Vipul Jain -
How to create a photo album in PPT- I use MS'2012 for MAC
how to create a photo album in PPT- I use MS'2012 for MAC
Hello pager7243,
Thank you for using Apple Support Communities.
The following explains how to set up an album on your iPhone with iOS 8.
iPhone User Guide For iOS 8 Software
Look at Chapter 11: Photos, Organize your photos and videos
Regards,
Jeff D.
Maybe you are looking for
-
Please see this screenshot: http://geoffmyers.net/images/mail_screenshot.png Since August 20, none of my sent emails have been saved by Mail (the account is IMAP). If you see the screenshot, you can see that, for some strange reason, Mail shows sever
-
In iPhoto 09 (8.1.2), I want to run slideshows of photos and videos. Using the space bar to stop/start a slideshow always brings up a slideshow control button. I want to suppress that display, which looks unprofessional. Using the navigation keys
-
I have created two classes but have an issue with the testdriver. Can someone let me know what the problem is? This is my class Person package pet; public class Person private String name; private String weight; private String sex; private MyDate bir
-
Can call an applet method directly in javascript?
I want to call an applet method directly in javascript as the following format: function test() ret_val = document.myapplet.mymethod(); myapplet is the applet name,mymethod is a public method in applet and it returns a string result,can that works? /
-
How to manage financial investments in SAP?
Good afternoon, what is the appropriate SAP module to Manage Financial Investments (participations), bearing in mind that we want to manage: - The existing shares; - The number of shares; - The acquisition cost (unit value); - Loans to group