plz give me one example and how to generate Driver of data base

mitmaya commented: how do use database for java +0

Recommended Answers

All 8 Replies

Database drivers (jdbc,odbc,.net...) are provided by database vendors or third party vendors and not generated. JDBC drivers are loaded into the JVM at runtime.

Please refer some books on JDBC Connectivity

to connect ms access with java
you have to datasource name

and write this code in ur program

Connection con=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:DSN name");
Statement stmt=con.createStatment();
ResultSet rs=stmt.executeQuery("select * from tablename");
while(rs.next())
{
System.out.println(rs.getSting("username"); //here username is the field name
}

the very first thing you need to do is to go to Control Panel --> adminstrative tools
then select the driver, and then your database

then you can write the code above mentioned in the reply above..
i guess that's pretty much it

Thanks for the help Guys, but I need to insert values in the database and I am using PreparedStatement to do this, the problem is I have created an applet but I am failed to know where do I need to put the connection or put the PreparedStatement.

For Example :
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Class A extends Applet {
{
public void init()
{
TextField t = new TextField();
Button b = new Button("SubmitRecords");
add(t);
add(b);
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Now this code create a simple applet with one textbox and button, I need to use insert statement to send the value of "t" in a field called "Names" in database on clicking the SubmitRecords Button. I am confused with the placement of the PreparedStatement and Connection Objects. Kindly help...!!

Thanks for the help Guys, but I need to insert values in the database and I am using PreparedStatement to do this, the problem is I have created an applet but I am failed to know where do I need to put the connection or put the PreparedStatement.

For Example :
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Class A extends Applet {
{
public void init()
{
TextField t = new TextField();
Button b = new Button("SubmitRecords");
add(t);
add(b);
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Now this code create a simple applet with one textbox and button, I need to use insert statement to send the value of "t" in a field called "Names" in database on clicking the SubmitRecords Button. I am confused with the placement of the PreparedStatement and Connection Objects. Kindly help...!!

Check this link ( <URL SNIPPED> ) for a reply to your question. Here you will find detailed description of how to connect to a SQL server database from a Java database application and pass embedded SQL queries. It describes how to create the connection string, pass parameters to the embedded SQL queries and stored procedures.

<FAKE SIGNATURE>

Thanks you very much, I am oblized.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.