aspose file tools*
The moose likes Java in General and the fly likes Annotation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Annotation error" Watch "Annotation error" New topic
Author

Annotation error

Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
I am unable to resolve the compilation error. Could you please help?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3553
    
  15
Originally posted by Sunder Ganapathy:
I am unable to resolve the compilation error. Could you please help?


Only if you tell us what the error is.


Joanne
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
annotation ch09.Resource is missing type
@Resource(name = "jdbc/bookdb") javax.sql.DataSource mydb;
^
src\ch09\AtResource.java:49: cannot find symbol symbol : variable mydb
location: class ch09.AtResource
connection = mydb.getConnection();
^
2 errors
Jeff Rummings
Ranch Hand

Joined: Dec 20, 2007
Posts: 42
The Resource annotation expects two arguments: a String name and a Class type. You're only passing it a string.

The second error is mydb is declared within the init() method, therefore you cannot access it from doPost().
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
If I add, type=javax.SQL.DataSource, the compiler says identifier expected.
I still find no clue about it.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

And if you try javax.SQL.DataSource.class?
javax.SQL.DataSource is the name of the class; javax.SQL.DataSource.class returns the Class object for it.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Annotation error