javascript using jdbc

i know to validate aform , but i don't no how to connect javascript to a database, plz help me. i only know to use jdbc.but this is only a client project for me , not to go on using internet.plz help me with a database
May 30,


String name = request.getParameter("name");
String ps = request.getParameter("psw");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
String url = "jdbc:odbc:login";
Connection con = null;
con= DriverManager.getConnection(url);
Statement st = con.createStatement();
//where name='"+nam+ "'";
//String sql= "SELECT * FROM login WHERE user = '"+name+ "'";
String sql = "SELECT * FROM login WHERE user='" + name + "'and psw='"+ps+"'";
//name='"+nam+ "',address='"+add+"',
ResultSet rs = st.executeQuery(sql);
String as = rs.getString(2);
String s = rs.getString(3);
if(name.equals(as) && ps.equals(s)){

else {
}catch(Exception e){
athar (032424037@umt.edu.pk)
March 19,
Well nandini,
UR question seems 2 b unclear...
through javascript u cannot connect 2 database
but using the above code in java ....u can get
connected ....but u say u dont want 2 use internet
than u can try for stand alone app. But still without
internet an intranet application can be built using
web interface.

March 22,
Javascript is client side. You simply cannot connect jdbc using javascript u need to have some serverside technology! .anything like java, php coldfusion or somethinglike that .
May 31,
hi ....
i ahve a project where i have to search for house ...
my website is in php and my database is in sql...and i have to use javascipt for search form can anybody help me and guide me how i can connect javascript with php and php to sql..
October 14,


1) connect to the database, perform your query and store the search results in an array, e.g. $MyResults

2) write a loop-like-function, which puts your SQL results in a string, e.g. $gridData, formatted like this (example for an two-dimensional results array, containing ID's and names):

mydata_columns = [
"ID", "name"];

mydata_data = [
["1", "Pete"],
["2", "John"]

3. Define another string in PHP, e.g. $gridCode, containing the Javascript code to initialize the grid:

try {
  var myGrid = new Active.Controls.Grid;
  myGrid.name = 'myName';
  myGrid.setRowCount(x);     //let php replace x by the amount of rows
  myGrid.setColumnCount(y); //let php replace y by the amount of columns
  myGrid.setDataText(function(i, j){return mydata_data[i][j]});
  myGrid.setColumnText(function(i){return mydata_columns[i]});

catch (error){
  alert('Datagrid error: '+error.description);

4. Finally, echo both the string in your PHP file:

echo $gridData;
echo $gridCode;

5. Of course you should also add the links to the Grid Javascript and CSS files in the head of your document (adjust the path in href)

<!-- ActiveWidgets stylesheet and scripts -->
<link href="../../runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/grid.js"></script>
<!-- ActiveWidgets PHP functions -->
October 16,

This topic is archived.

See also:

Back to support forum