-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi guy !
firstly i dont speak english very well. so forgive me for my mistakes.
i work with zk and eclipse and oracle . I try to make a login window.
I already test the connection with oracle .
Driver , url and my query sql work well. when i run it by doing a Run Java Application (it mean that i do a main in my class java).
But when i remove the main and try to make the connection with zul login file ;
i got and error ;
Drive not found ...
This is the structure of my java class.
public static String verifiCoord (Textbox log2,Textbox pd2) { //je linitialise pas car la methode appele est en static . String login = log2.getValue(); String pwd = pd2.getValue(); ResultSet rs; try { String driverName = "oracle.jdbc.driver.OracleDriver"; Class.forName(driverName); System.out.println("driver trouveeeeeeeee"); } catch (ClassNotFoundException e) { System.out.println("Driver classe non trouveeeeeeeeeee"); } try{ connect=DriverManager.getConnection("jdbc:oracle:thin:@dellprecision:1521:metuu","scott","azerty"); }catch(SQLException e){ System.out.println("Connection impossibleeeeeeeeee base de donnees" +e); } try{ Statement s=connect.createStatement(); String sql="select login from usersesion where login ='"; sql+=login; sql+="'"; sql+="and pwd='"; sql+=pwd; sql+="'"; rs=s.executeQuery(sql); retourChaine = rs.getString(1); s.close(); }catch(SQLException s){ System.out.println("erreur requete"+s.getMessage()); } System.out.println("valeur de ma chaine"+retourChaine); return retourChaine; }
Here is my zul file
<?page title="Authentification Utilisateur" ?> <window title="Authentification Utilisateur" width="300px" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:zk="http://www.zkoss.org/2005/zul" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul" id="auth_window" border="none"> <zscript > <![CDATA[//@IMPORT import course.Login; import course.Entry;]]> <![CDATA[//@DECLARATION Entry e = new Entry(); Login l = new Login(); ]]> </zscript> <grid> <rows> <row><label value="Nom d'utilisateur"/></row> <row><textbox id="username"></textbox></row> <row> <label value="Mot de passe"/></row> <row><textbox id="pwd"></textbox></row> <row><button label="Se connecter" onClick="l.verifiCoord(username,pwd);"></button></row> </rows> </grid> </window>
in the console i get these errors;
Driver classe non trouveeeeeeeeeee Connection impossibleeeeeeeeee base de donneesjava.sql.SQLException: No suitable driver 23 avr. 2010 16:20:02 org.zkoss.zk.ui.impl.UiEngineImpl handleError:1130 GRAVE: >>java.lang.NullPointerException >> at course.Login.verifiCoord(Login.java:42) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
I precise that i dont want to use a persistence tool like hibernate.
thank u for your help
i had similiar problem :/
Hello fatimatall, nirmalsri, and wiles,
You have to place the driver under the path /WebContent/WEB-INF/lib
Please find at the folllowing url an associated example:
http://books.zkoss.org/wiki/ZKDeveloper'sReference/Integration/Persistence_Layer/JDBC
Best Regards,
Darksu
THANKS works really well!
Did you put the driver under WEB-INF/lib too? I guess that's the reason you can't find the driver in Servlet.
http://pottytraininganswers.com (Potty Training) | http://pottytraininganswers.com/potty-training-101.html (Potty Training Tips) | http://pottytraininganswers.com/potty-training-girls.html (Potty Training Girls) | http://pottytraininganswers.com/potty-training-boys.html (Potty Training Boys) |
Asked: 2010-04-23 09:38:34 +0800
Seen: 1,511 times
Last updated: Nov 04 '14