In my implementation of methods I have errors that arise in my class videoDaoIplm.java.
here is my code:
I would like to understand why it displays this error, while the other methods do not display errors?
Philippe Ponceblanc wrote: do not understand the meaning of your question
Usually when people experiencing some compilation errors or run-time exceptions we usually ask them to provide stack traces.
Stack traces pretty clearly identify the exact problem(s).
In short - if stack trace says i.e.:
That means you possibly don't have declared such method as getConnection() (not saying it is your problem currently), or got some typo either in a method call or method declaration.
Is clearer now?
i anderstand !
Creates a Statement object for sending SQL statements to the database. SQL statements without parameters are normally executed using Statement objects. If the same SQL statement is executed many times, it may be more efficient to use a PreparedStatement object.
Result sets created using the returned Statement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability.
a new default Statement object
SQLException - if a database access error occurs or this method is called on a closed connection
The method setfichier(String) is undefined for the type Video
The method add(Video) is undefined for the type Video
The error messages say that there are no static methods in the class Video which have those names. So we don't have to guess about that. But the names you used are normally used for instance methods, so we could guess that you did that. And if you did, and you expected them to be used in that code, well... somebody already posted that you're calling them on the class Video and not the variable video.
By the way, those setter methods: in the standard JavaBean style you would call them setFichier and not setfichier, and so on.
Your error messages are all about the Video class and you have not released the code for this class. Once again we have to guess.
>> Now you have the video class, and I wonder why it takes static methods?
The error messages indicate that there are no static methods in the Video class that have these names. So we do not have to guess about it.
>> yes you understand!
But the names you used are normally used for example methods, so we might guess that you did that.
>> I am inspired by the model DAO of my course that I am!
And if you did, and you expected them to be used in this code,
>> here I do not understand I just want to know:
>> 1 / the path and file name to load the right video!
>> 2 / I do not understand this sentence?
well ... someone has already posted that you call them on the video of the class and not on the variable video.
>> I do not mix the class and variabbles I'm not so stupid
By the way, these setter methods: in the standard JavaBean style, you would call them setFile and not setfile, and so on.
>> here I understand that I made annotation errors!
DAO> now that I've been writing for a long time that you have to create an interface, then declare the methods and finally implement the methods it's like in C ++.
but it's not so obvious that it may seem
how do you also say that a CAD design pattern is not easy to set up
and especially a piece of code and often more understanding than to speak is like drawing a picture to explain
so explain me please
In the first line you create a Video object and assign the reference to the video variable.
Then on the second line you do not use the video variable...you are using the Video class name.
The compiler thinks you want to run a static method called setfichier that is part of the Video class.
This looks like a typo, and you actually wanted to use the video variable and not the class.
now I have a 500 error:
in line 62 i have this code ;
in the servlet ligne 47 :
I'm nothing done in this method, I'm sure there is something to do with hands I do not know!
This is the first time I use "static" methods in JavaEE.
what should you do to return an argument instead of null?
it's not VideoFactory but DaoFactory, this is where I put the parameter statement for connection with MySql!
here is the complete code of DaoFactory, I repeat myself! lol
Carey Brown wrote:Look up the DriverManager class. There are a few getConnection() methods to choose from.
I read your documentation and I am aware that 'getconnection' is already declared in the DaoFactory and my implementation class (VideoDaoImpl) does not take into account Daofoctory, why it does not make the link between the two class java c is DaoFactory and VideoDaoIml; I do not understand why he does not make the link while they are both in the same package?
You'll find a link to the documentation for all sorts of Java versions here: https://docs.oracle.com/javase/8/docs/api/ and you can click on the link there to go to the version you use.
I changed mine to setProperty() because that's the correct one to use but I don't know why no problems showed up with put().
Carey Brown wrote:Yes.
Paul Clapham wrote:And this "Properties" class: it is java.util.Properties, isn't it?
I asked because I didn't see any import statement for Properties. And also because after I posted my first response, I realized that the put(String, String) method should compile successfully. So that led me to suspect that some other Properties file had inadvertently been used.
An add() method is "usually" used to add an instance to a collection. Your collection is a List<Video> whose name is "videos" with a lower case "v". So to add your new "video" instance to your "videos" list you need
(Haven't we been here before?)
What does this do?