• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

File IO in Stateless Session bean

 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Requirement : Read contents of a text file and upload the same to Oracle database (table).

I have created a Java class (application kind of) which opens, reads a file and transfers its data to a Oracle table.

Can I instantiate the same class within a Session Bean to perform the same operation or as per the EJB Restrictions this is not supposed to be done?

EJB Specifications 2.1 pdf guide
(refer 25.1.2 Programming restrictions
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.
)

Awaiting ur responses at the earliest.

Thanking in advance,

Seetesh
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ya...
yeah ure right...the EJB specs specifically says that EJBS cannot perform file i/o. if u need to log messages or access files, you must find another mechanism...
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a quick follow up.... rather a doubt...
How does Log4J work with EJB's then???
 
Aboo Bolaky
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The other mechanism as Rajan pointed out is Log4J..
have a look at Vikram Goyal's introductory explanation
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Aboo and Rajan,

Thks for ur post. I am using Log4J but my query was that I want to read a file (txt file) and insert its contents in a oracle table.

I have one file called FileIO.class which does the same. Question is If I instantiate this class in a business method of Stateless Session Bean and call the appropriate method of uploading the file contents in a oracle table, will it create any issues?

I am not bothered abt transaction issues here.

Rgds,

Seetesh
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can have a util class. which could has a method which reads the file and returns a string. just call that method from your bean, pass the filename and get the string.

how it sounds?
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just trying the same. Will revert back shortly.

Seetesh
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic