Hi
i m new in mysql plz any one help me how can i solve a problem.
i m using this code for connection file
package connect;
import java.sql.*;
public class Connect
{
private static Connection con=null;
public static Connection getConnection()
{
try
{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
con =DriverManager.getConnection("jdbc:mysql://localhost:3306/rsdatabase","root","root");
System.out.println("Connection Established");
return con;
}
catch(Exception e)
{
System.out.println("Error Loading Driver" +e);
}
return con;
}
}
and also made this page
package services;
import java.sql.*;
import java.io.*;
import java.util.*;
import connect.Connect;
public class login1
{
Vector v=null,v1=null,v2=null,v3=null,v4=null,v5=null,v6=null,v7=null,v8=null;
Connection con=null;
Statement stmt=null,stmt1=null,stmt2=null;
ResultSet rs=null,rs1=null,rs2=null;
PreparedStatement ps=null,ps1=null,ps2=null;
public login1() {
try {
con=Connect.getConnection();
}
catch(Exception e)
{
System.out.println("Exception:"+e);
}
}
public boolean logincheck(String username,String password) {
try{
String aa="Select * from user_pass where UserName=(?) and password=(?)";
ps=con.prepareStatement(aa);
ps.setString(1,username);
ps.setString(2,password);
rs=ps.executeQuery();
if(rs.next()){
return true;
}
}
catch(Exception s) {
System.out.println("Error" +s);
}
return false;
}
public String getType(String username,String password) {
try{
String aa="Select * from user_pass where UserName=(?) and password=(?)";
ps=con.prepareStatement(aa);
ps.setString(1,username);
ps.setString(2,password);
rs=ps.executeQuery();
if(rs.next()){
return rs.getString("AccessType");
}
}
catch(Exception s) {
System.out.println("Error" +s);
}
return "-";
}
public static void main(String args[]) {
login1 ll=new login1();
boolean b=ll.logincheck("admin","admin");
System.out.println(b);
}
}
i m using tomcat 4.0 and
if i m insert a id and pwd admin,admin then give the error
Database Connection does not exist
plz help me how can i solve this problem