hi
i create a package connection and in that i wrote the following program
package connection;
import java.sql.Driver Manager;
import java.sql.Connec tion;
import java.io.*;
public class connect
{
Connection conn;
public connect()
{
try{
Class.forName(" com.mysql.jdbc. Driver");
}
catch(Exception e)
{}
}
public Connection getConnection()
{
try{
conn=DriverMana ger.getConnecti on("mysql:mysql ://localhost/college","root" ,"");
}catch(Exceptio n e){}
return conn;
}
}
----------------------
and compiled it. it got compiled then coming out from connection package and once again i created sql package and in that i wrote the following program.
package sql;
import connection.*;
import java.sql.*;
public class SqlBean
{
Connection con=null;
public SqlBean()
{
connect c=new connect();
con=c.getConnec tion();
}
// Insert the records into database
public int insert(String query)
{
int i=0;
try
{
Statement st=con.createSt atement();
i=st.executeUpd ate(query);
}
catch(Exception sql)
{
sql.printStackT race();
}
return i;
}
// it is used to update the records
public int update(String query)
{
int i=0;
try
{
Statement st=con.createSt atement();
i=st.executeUpd ate(query);
}
catch(Exception sql)
{
sql.printStackT race();
}
return i;
}
// it is used to select the records based on Query
public ResultSet select(String query)
{
ResultSet rs=null;
try
{
Statement st=con.createSt atement();
rs=st.executeQu ery(query);
return rs;
}
catch(Exception sql)
{
sql.printStackT race();
}
return rs;
}
// to close the connection (con)
public void close()
{
try
{
if(con!=null)
{
con.close();
}
}catch(Exceptio n e)
{
e.printStackTra ce();
}
}
}
-------------
while compilng it is giving the following error "PACKAGE NOT FOUND". can any one what the mistake i did. waiting for reply
regards
i create a package connection and in that i wrote the following program
package connection;
import java.sql.Driver Manager;
import java.sql.Connec tion;
import java.io.*;
public class connect
{
Connection conn;
public connect()
{
try{
Class.forName(" com.mysql.jdbc. Driver");
}
catch(Exception e)
{}
}
public Connection getConnection()
{
try{
conn=DriverMana ger.getConnecti on("mysql:mysql ://localhost/college","root" ,"");
}catch(Exceptio n e){}
return conn;
}
}
----------------------
and compiled it. it got compiled then coming out from connection package and once again i created sql package and in that i wrote the following program.
package sql;
import connection.*;
import java.sql.*;
public class SqlBean
{
Connection con=null;
public SqlBean()
{
connect c=new connect();
con=c.getConnec tion();
}
// Insert the records into database
public int insert(String query)
{
int i=0;
try
{
Statement st=con.createSt atement();
i=st.executeUpd ate(query);
}
catch(Exception sql)
{
sql.printStackT race();
}
return i;
}
// it is used to update the records
public int update(String query)
{
int i=0;
try
{
Statement st=con.createSt atement();
i=st.executeUpd ate(query);
}
catch(Exception sql)
{
sql.printStackT race();
}
return i;
}
// it is used to select the records based on Query
public ResultSet select(String query)
{
ResultSet rs=null;
try
{
Statement st=con.createSt atement();
rs=st.executeQu ery(query);
return rs;
}
catch(Exception sql)
{
sql.printStackT race();
}
return rs;
}
// to close the connection (con)
public void close()
{
try
{
if(con!=null)
{
con.close();
}
}catch(Exceptio n e)
{
e.printStackTra ce();
}
}
}
-------------
while compilng it is giving the following error "PACKAGE NOT FOUND". can any one what the mistake i did. waiting for reply
regards
Comment