0

How to connect oracle zul file and java file

asked 2010-04-23 09:38:34 +0800

fatimatall gravatar image fatimatall
6 1

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

delete flag offensive retag edit

15 Replies

Sort by ยป oldest newest

answered 2014-10-28 12:09:43 +0800

nirmalsri gravatar image nirmalsri
1

hai friends i am facing class not found exception. com.mysql.jdbc.Driver

already i have configure mysql driver but repeated same error.

link publish delete flag offensive edit

answered 2014-10-28 14:16:47 +0800

wiles gravatar image wiles
1
http://www.celoszczedzani...

i had similiar problem :/

link publish delete flag offensive edit

answered 2014-11-02 22:43:44 +0800

Darksu gravatar image Darksu
1991 1 4

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

link publish delete flag offensive edit

answered 2014-11-03 07:28:26 +0800

wipekk gravatar image wipekk
1
http://www.rzadzapieniadz...

THANKS works really well!

link publish delete flag offensive edit

answered 2014-11-04 16:58:03 +0800

sandralambert gravatar image sandralambert
1
http://www.pottytraininga...

updated 2014-11-04 16:58:35 +0800

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) |

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-04-23 09:38:34 +0800

Seen: 1,495 times

Last updated: Nov 04 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More