This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error accessing a static method (JSP, Java)

 
Kyupa Supa
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP file
......................................…

......................................…
______________________________________…

Java file
________


......................................…

The error says:

- The method fillStudents(String, int) is undefined the type StudentsManager.

The warning says:

- The static method fillStudents(String, int) from the type StudentsManager should be accessed in a static way.

I really don't know what to do.
 
Stefan Evans
Bartender
Posts: 1640
9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The getInstance() method seems to indicate you are trying to use a singleton pattern.
Generally with that pattern, the getInstance() method should be static, but none of the other methods on the class.

You obtain the object via the call to getInstance() and then invoke the non static methods on that object.
so



The database code looks a bit dodgy as well.
What is the ConnectionsManager class?
You get both a connection and a statement from it, but then only use the statement.
The general way to use it would be to obtain a connection, and then create the statement from the connection object.
I would also recommend using prepared statements over sql strings like you have to guard against sql injection.

 
Kyupa Supa
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked the way you said (with leaving away the "static") for the rest of the methods :)

I use only Statement, but invoking the connection method as well because they are bound together:



The ConnectionsManager.java is:



Concerning PreparedStatement, you're the second one saying that, but well I'm using that insert statement only once.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64189
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Diana Sarbu wrote:you're the second one saying that, but well I'm using that insert statement only once.

So? Is that a good reason to leave your site open to SQL injection?
 
Kyupa Supa
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote: So? Is that a good reason to leave your site open to SQL injection?


I read now on Wiki about this. I don't want to sound rude or something but, look, I'm not working on a commercial software now. I'm just making a project and my prof. said to use just Statements, plus I would have to write a few methods more in the java file and I really don't have the time right now. I need to make my project full and working and afterwards, with the remaining time(i hope i'll have it) I'll try to see what I can change in some parts.



 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic