Reading data from file in EJB
I would like to read data from files in EJBS (Stateless Session Bean I think). I've heard that the EJB sepcifications don't allow to use the java.io package to access the filesystem. How can I resolve this problem? Possible solutions I've thought of are:
* Use a webserver to store the data
* put the files in a jar and access them using the getResource() in the classloader class
Could you comment on this plesae
greetings
The specification states:
"An enterprise bean must not use the java.io package to attempt to access files and directories in the file system.
The file system APIs are not well-suited for business components to access data. Business components should use a resource manager API, such as JDBC, to store data."
From this I understand I cannot acces files directly, but it does not specifiy I can't use the java.io package at all. It specifically says not to use the java.io package to acces files and directories, they don't say anything about using the classes for other use.
however, a litle lower the specification states:
"The enterprise bean must not attempt to create a class loader; obtain the current class loader; set the context class loader; set security manager; create a new security manager; stop the JVM; or change the input, output, and error streams.
These functions are reserved for the EJB Container. Allowing the enterprise bean to use these functions could compromise security and decrease the Container�s ability to properly manage the runtime environment."
I'm not sure how to interpret this, but I believe this rule makes my solution invalid.
Please comment on this,
thanks
Similar Messages
-
How to read data from a file in OSB
hi guys,
Recently, I've got a problem with reading file from specific location. I've actually followed this post OSB 11g - Read or Poll File in OSB - Oracle Fusion Middleware Blog, and then
I know how to read a file. However, it does not as expected. Because, I've found no way to read data from the file. Therefore, no chance to manipulate the data like assigning to a variable, or extracting ....
Hence, is there any way to read data from file by using proxy service in OSB ??? No Java code ???
by the way, supposed that there is no way to read data from a file in OSB. So, What purposes will the way in the post above be used for?
Many thanks in advancehttp://jakarta.apache.org/poi/hssf/index.html
HSSF stands for Horrible Spreadsheet Format, but it still works! -
View Object to read data from a java file
Hi,
I am using JDeveloper 11.1.1.4 and ADF-BC in my application.
For one of my view objects , I want the data to be read from a java file which exposes some method to return a collection.
I cannot use a static view object in this case.
Please suggest the best way to implement this requirement.Basically build a view object that should read data from a java file.
Thanks,
PraveenDepending on your use case you can either use a programmatic VO or directly expose the JV class as a data control.
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html -
How to read data from multiple files and append in columns in one file
Hi Guys,
I have a problem in appending data from files in different columns. I have attachement has file A and B which I am reading and not able to get data as in file Result.txt. Please comment on how can I do this
Solved!
Go to Solution.
Attachments:
Write to file.vi 13 KB
A.txt.txt 1 KB
B.txt.txt 1 KBYou cannot append columns to an existing file. Since the data is arrange line-by-line as one long linear string in the file, you can only append rows. A new row needs to be interlaced into the original file, shifting everything else. If you want to append rows, you need to build the entire output structure in memory and then write all at once.
(I also don't think you need to set the file positions, it will be remembered from the last write operation.)
Unless the files are gigantic, here's what I would do:
(Also note that some of your rows have an extra tab at the end. If this is normal, you need a little bit more code to strop out empty columns. I include cleaned up files in the attachment. I also would not call them A.txt.txt etc. A plain A.txt is probably sufficient.)
EDIT: It seems Dennis's solution is similar )
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Write to fileMOD.zip 6 KB
MergeColumns.png 6 KB -
Read data from a text file, one line at a time.
I need to read data from a text file, and display each line in a String Indicator on Front Panel. It displays each line, but I get Error 4, End Of Line, unless I enter an extra line of data in the file that I don't need. I tried Read From Text File.vi, made by Nat Instr, and it gave the same error.
The Read from Text File.vi reads data from a text file line by line until the user stops the VI manually with the Stop button on the front panel, or until an error (such as "Error 4, End of file") occurs. If an error occurs, the Simple Error Handler.vi pops up a dialog that tells you which error occurred.
The Read from Text File.vi uses a while loop, but if you knew how many lines you wanted to read, you could replace the while loop with a for loop set to read that many lines from the file.
If you need something more dynamic because the number of lines in your files vary, then you could change the code of the Read from Text File.vi to the expect "Error 4, End of file" and handle it appropriately. This would require unbundling the error cluster that comes fro
m the Read File function with the Unbundle By Name function, so that you can expose the individual error "status" and error "code" values stored in the cluster. If the value of the error "code" is 4, then you can change the error "status" from true to false, and you can rebundle the cluster with the Bundle by Name function. Setting the error "status" to false instructs the Simple Error Handler to ignore the error. Otherwise, pass the original error cluster to the Simple Error Handler.vi, so that you can see what the error is.
Of course, if you're not interested in what the errors are, you could just remove the Simple Error Handler.vi, but then you wouldn't see any error messages.
Best of Luck,
Dieter
Dieter Schweiss
Applications Engineer
National Instruments -
How to read data from a file that was formatted by excel?
Hi everyone, I'm familiar with java.io and the ability to read from files, can anyone tell me how to read data from a file that was formatted by excel? Or at least give me some web references so that I can learn about it?
http://jakarta.apache.org/poi/hssf/index.html
HSSF stands for Horrible Spreadsheet Format, but it still works! -
How to read data from a zipped MS Access file?
How to read data from a zipped MS Access file?
RPJ,
You do not need to use the Close Zip File.vi when you unzip a folder. This VI is used when you are creating a zip folder.
As for examples, I found a couple of ActiveX based MS Access examples. These programs look to be pretty basic. For more in depth example I would search Microsoft Developers Network
http://zone.ni.com/devzone/cda/epd/p/id/2188
http://zone.ni.com/devzone/cda/epd/p/id/1694
Regards,
Jon S.
National Instruments
LabVIEW R&D -
Reading Data from a SQL table to a Logical file on R/3 appl. Server
Hi All,
We would like to create Master Data using LSMW (direct Input) with source files from R/3 Application Server.
I have created files in the'/ tmp/' directory however I do not know how to read data from the SQL table and insert it into the logical file on the R/3 application server.
I am new to ABAP , please let me know the steps to be done to acheive this .
Regards
- AjayHi,
You can find lot of information about Datasets in SCN just SEARCH once.
You can check the code snippet for understanding
DATA:
BEGIN OF fs,
carrid TYPE s_carr_id,
connid TYPE s_conn_id,
END OF fs.
DATA:
itab LIKE
TABLE OF fs,
w_file TYPE char255 VALUE 'FILE',
w_file2 TYPE char255 VALUE 'FILE2'.
SELECT carrid connid FROM spfli INTO TABLE itab.
OPEN DATASET w_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
" Server to write data
LOOP AT itab INTO fs.
TRANSFER fs TO w_file. "" Writing the data into the Application server file
ENDLOOP.
CLOSE DATASET w_file.
OPEN DATASET w_file FOR INPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
" server to read data
FREE itab.
DO.
READ DATASET w_file INTO fs.
IF sy-subrc EQ 0.
APPEND fs TO itab.
OPEN DATASET w_file2 FOR APPENDING IN TEXT MODE ENCODING DEFAULT. "Appending more data to the file in the
" application server
TRANSFER fs TO w_file2.
CLOSE DATASET w_file2.
ELSE.
EXIT.
ENDIF.
ENDDO.
Regards
Sarves -
Reading data from an excel file
Hi,
I want to read data from the excel file and display it in
jsp page. Iam getting the following error:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =
DriverManager.getConnection("jdbc:odbc:mydsn","","");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from [holidays$]");
Here i have created the dsn with the name "mydsn". I have the
following data in the mydsn.dsn file:
[ODBC]
DRIVER=Microsoft Excel Driver (*.xls)
UID=admin
UserCommitSync=Yes
Threads=3
SafeTransactions=0
ReadOnly=1
PageTimeout=5
MaxScanRows=8
MaxBufferSize=2048
FIL=excel 8.0
DriverId=790
DefaultDir=D:\WorkSpace\Projects\VINET\devl\webroot\jsp
DBQ=D:\WorkSpace\Projects\VINET\devl\webroot\jsp\list_of_holidays_2003.xls
thanks in advance
phani.You might want to look at the POI project (an open source Jakarta sub-project) that allows you to create/modify/read excel files via Java code. That might be more flexible and easier than what you're currently trying to do.
Cheers -
GUI_UPLOAD to read data from an Excel File
Hi Folks,
I'm using FM GUI_UPLOAD to read data from an Excel File. But all I see in the table returned is 1 row with garbage values (special chacaters). Excel Workbook has proper data in the sheet, but its not getting uploaded properly. Sy-subrc is 0.
What could be the reason?
Thanksuse FM : ALSM_EXCEL_TO_INTERNAL_TABLE
See the example program to get from XLS file to Internal table
REPORT ZLWMI151_UPLOAD no standard page heading
line-size 100 line-count 60.
*tables : zbatch_cross_ref.
data : begin of t_text occurs 0,
werks(4) type c,
cmatnr(15) type c,
srlno(12) type n,
matnr(7) type n,
charg(10) type n,
end of t_text.
data: begin of t_zbatch occurs 0,
werks like zbatch_cross_ref-werks,
cmatnr like zbatch_cross_ref-cmatnr,
srlno like zbatch_cross_ref-srlno,
matnr like zbatch_cross_ref-matnr,
charg like zbatch_cross_ref-charg,
end of t_zbatch.
data : g_repid like sy-repid,
g_line like sy-index,
g_line1 like sy-index,
$v_start_col type i value '1',
$v_start_row type i value '2',
$v_end_col type i value '256',
$v_end_row type i value '65536',
gd_currentrow type i.
data: itab like alsmex_tabline occurs 0 with header line.
data : t_final like zbatch_cross_ref occurs 0 with header line.
selection-screen : begin of block blk with frame title text.
parameters : p_file like rlgrap-filename obligatory.
selection-screen : end of block blk.
initialization.
g_repid = sy-repid.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = g_repid
IMPORTING
FILE_NAME = p_file.
start-of-selection.
Uploading the data into Internal Table
perform upload_data.
perform modify_table.
top-of-page.
CALL FUNCTION 'Z_HEADER'
EXPORTING
FLEX_TEXT1 =
FLEX_TEXT2 =
FLEX_TEXT3 =
*& Form upload_data
text
FORM upload_data.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = $v_start_col
I_BEGIN_ROW = $v_start_row
I_END_COL = $v_end_col
I_END_ROW = $v_end_row
TABLES
INTERN = itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
write:/10 'File '.
ENDIF.
if sy-subrc eq 0.
read table itab index 1.
gd_currentrow = itab-row.
loop at itab.
if itab-row ne gd_currentrow.
append t_text.
clear t_text.
gd_currentrow = itab-row.
endif.
case itab-col.
when '0001'.
t_text-werks = itab-value.
when '0002'.
t_text-cmatnr = itab-value.
when '0003'.
t_text-srlno = itab-value.
when '0004'.
t_text-matnr = itab-value.
when '0005'.
t_text-charg = itab-value.
endcase.
endloop.
endif.
append t_text.
ENDFORM. " upload_data
*& Form modify_table
Modify the table ZBATCH_CROSS_REF
FORM modify_table.
loop at t_text.
t_final-werks = t_text-werks.
t_final-cmatnr = t_text-cmatnr.
t_final-srlno = t_text-srlno.
t_final-matnr = t_text-matnr.
t_final-charg = t_text-charg.
t_final-erdat = sy-datum.
t_final-erzet = sy-uzeit.
t_final-ernam = sy-uname.
t_final-rstat = 'U'.
append t_final.
clear t_final.
endloop.
delete t_final where werks = ''.
describe table t_final lines g_line.
sort t_final by werks cmatnr srlno.
Deleting the Duplicate Records
perform select_data.
describe table t_final lines g_line1.
modify zbatch_cross_ref from table t_final.
if sy-subrc ne 0.
write:/ 'Updation failed'.
else.
Skip 1.
Write:/12 'Updation has been Completed Sucessfully'.
skip 1.
Write:/12 'Records in file ',42 g_line .
write:/12 'Updated records in Table',42 g_line1.
endif.
delete from zbatch_cross_ref where werks = ''.
ENDFORM. " modify_table
*& Form select_data
Deleting the duplicate records
FORM select_data.
select werks
cmatnr
srlno from zbatch_cross_ref
into table t_zbatch for all entries in t_final
where werks = t_final-werks
and cmatnr = t_final-cmatnr
and srlno = t_final-srlno.
sort t_zbatch by werks cmatnr srlno.
loop at t_zbatch.
read table t_final with key werks = t_zbatch-werks
cmatnr = t_zbatch-cmatnr
srlno = t_zbatch-srlno.
if sy-subrc eq 0.
delete table t_final .
endif.
clear: t_zbatch,
t_final.
endloop.
ENDFORM. " select_data -
Help! How to read data from an Excel file?
Hi,
I need to read data from an Excel file that may contain more then one table in a sheet. How can I read them?
I would be eternally grateful to anyone who can give me any information.Did you try POI from Apache?
http://jakarta.apache.org/poi/index.html -
Static lookup lists:read data from a Java *.properties file
Hi
i need to make static lookup lists i am using read data from a Java *.properties file
i am using the Class "PropertyFileBasedLookupViewObjectImpl" that wrote by Steve Muench in ToyStore.
but i need to use the default language for that i update the loadDataFromPropertiesFile()
method to find the correct properties file
String temp=Locale.getDefault().getLanguage();
String propertyFile =
getViewDef().getFullName().replace('.', '/')+"_"+temp+ ".properties";
the problem:
For English(TEST_en.properties) it is good and working
For Arabic(TEST_ar.properties) read from correct file _ar.properties
but the dispaly character is wrong
When Debug
In the File 1=دمشق
In debug 1=/u32423Depending on your use case you can either use a programmatic VO or directly expose the JV class as a data control.
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html -
HOW TO READ DATA FROM A FILE AND INSERT INTO A TABLE USING UTL_FILE
Hi..
I have a file.I want to read the data from file and load it into a table using utl_file.
how can I do it?
Any reply apreciated...Hi,
This is not your requirment but u can try this :
CREATE OR REPLACE DIRECTORY text_file AS 'D:\TEXT_FILE\';
GRANT READ ON DIRECTORY text_file TO fah;
GRANT WRITE ON DIRECTORY text_file TO fah;
DROP TABLE load_a;
CREATE TABLE load_a
(a1 varchar2(20),
a2 varchar2(200))
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY text_file
ACCESS PARAMETERS
(FIELDS TERMINATED BY ','
LOCATION ('data.txt')
select * from load_a;
CREATE TABLE A AS select * from load_a;
SELECT * FROM A
Regards
Faheem Latif -
How to read data from a file that is already open by another program
Hey..
I have made IV, where I'm trying to read data from a log file, that is being updated by another program while my IV runs.
To be clear, this program writes data continuously to this file and I want to read from the file in LV at the same time.
The problem is that LV reports an error when I'm trying to read the log file, even if I use to "read only" mode.
I believe that the program that is producing the file, have some kind of lock on the file. I have tryed to copy the file and then reading from the copied file, but LV throws already an error when I try to copy the file.
Has anyone tryed this, and found a solution.?
Additional info: The program that produces the file is STM Studio
Best Regards
AllanHi Alha,
when that file is locked by the other program you can't do anything about that - apart from quitting that other program. Probably this isn't an option to you…
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
Read data from a log file to flex textarea while deploying
Hi,
I am new to flex. I am able to read data from a log file that placed in C drive and able to write that data into flex textarea, but I am unable to read the same file while it is deployed into weblogic sever.
Could anyone please tell me how to solve this problem.
Thanks,
Sri.Do you have it trying to read that same file on your C drive or is the file actually deployed somewhere on the server?
Maybe you are looking for
-
Error in activating Transformation
Hi Gurus We are using BI 7.0 and when we use amonut as a data type for one of the key figure ( Revenue ) , I am getting an error when I am trying to activate the transformation. Do you know which OSS note/ Support pack we have to apply? Thanks
-
I can't get iTunes to play any songs, whether they are in my library or a preview in the iTunes store. I have upgraded itunes, uninstalled/reinstalled quick time and still nothing. The song does load, but nothing plays and progress bar doesn't move.
-
i have a macbook 2009 with osx mavericks (10.9.4). so i was watching youtube, then suddenly my macbook freezes and i can't do nothing about it. so i force shutdown and turn it on again. when it's on, my speaker is not working and when i check the sou
-
Convert varchar(255) to varchar(50)
I want to transfer data from a staging table to another table. The staging table has columns with datatypes I don't always want, and I'm converting them like so: INSERT INTO [dbo].[my_table] SELECT CONVERT(datetime,TimeIndex,103), CONVERT(decimal(6,3
-
Hi everyone, I made this Password Generator that does what I want, but I'd like to extend its functionality. Right now it creates a random password from an array of letters and numbers. import java.io.*; import javax.swing.*; import java.util.*; *Ver