Vindhya,

Getting back to the root of your original question, you can't connect
directly to a database with GWT because there's no way to connect to a
database directly from JavaScript. Instead, you create a GWT service
and implement it on the server, where you can connect to a database
using JDBC or any Java persistence framework. Here's an article on
using GWT with Hibernate that you will hopefully find helpful:

http://code.google.com/webtoolkit/articles/using_gwt_with_hibernate.html

And this link explains how to communicate with the server using GWT-RPC:

http://code.google.com/webtoolkit/doc/latest/DevGuideServerCommunication.html

/dmc

On Thu, Dec 9, 2010 at 2:51 PM, Vindhya <vin...@gmail.com> wrote:
> Hello Friends,
>
> I am new to GWT and I am developing an application, - a form based
> one, to insert/delete/edit tuples in a set of tables.
>
> I am facing problems with the connectivity to the database.
>
> I kept getting an error:
> java.sql.Connection can not be found in source packages. Check the
> inheritance chain from your module; it may not be inheriting a
> required module or a module may not be adding its source path entries
> properly.
>
> The code I wrote is as follows:
>
> <code>
> package com.company.rulesengine.client;
>
> import java.sql.*;
>
> import com.google.gwt.core.client.EntryPoint;
> import com.google.gwt.event.dom.client.ClickEvent;
> import com.google.gwt.event.dom.client.ClickHandler;
> import com.google.gwt.user.client.Window;
> import com.google.gwt.user.client.ui.Button;
> import com.google.gwt.user.client.ui.RootPanel;
> import com.google.gwt.user.client.ui.Label;
> import com.google.gwt.user.client.ui.TextBox;
>
> /**
>  * Entry point classes define <code>onModuleLoad()</code>.
>  */
>
> public class RulesEngineUI implements EntryPoint {
>
>        public Connection conn= null;
>
>        RulesEngineUI()
>        {
>                //establishing a database connection
>
>            try
>            {
>              Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
>              String url = "<<url>>";
>              conn = DriverManager.getConnection(url, "SYSTEM", "vindhya");
>             // doTests();
>                 System.out.println("DONE!");
>              conn.close();
>            }
>            catch (Exception ex) {System.err.println(ex.getMessage());}
>
>          }
>        private Button clickMeButton;
>        public void onModuleLoad()
>        {
>
>                RootPanel rootPanel = RootPanel.get();
>
>                clickMeButton = new Button();
>                rootPanel.add(clickMeButton, 232, 236);
>                clickMeButton.setText("Insert");
>
>                Label lblEmployeeId = new Label("Employee ID");
>                rootPanel.add(lblEmployeeId, 30, 61);
>
>                Label lblName = new Label("Employee Name");
>                rootPanel.add(lblName, 26, 142);
>
>                TextBox textBox = new TextBox();
>                rootPanel.add(textBox, 233, 59);
>
>                TextBox textBox_1 = new TextBox();
>                rootPanel.add(textBox_1, 232, 142);
>                clickMeButton.addClickHandler(new ClickHandler(){
>                        public void onClick(ClickEvent event) {
>                                Window.alert("Hello, GWT World!");
>                        }
>                });
>        }
> }
> </code>
>
> Any help in this regard will be well appreciated.
>
> Thank you,
> Vindhya
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-tool...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-web-toolkit+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>



-- 
David Chandler
Developer Programs Engineer, Google Web Toolkit
http://googlewebtoolkit.blogspot.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to