How to connect and control the database to the webpage (using Java and HTML)?

Tags:
Database
HTML
Java
Would anyone know how to connect and control a database to the webpage (using Java and HTML)?


Software/Hardware used:
Eclipse IDE
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

The JDBC-ODBC bridge provides JDBC access via most ODBC drivers.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;

public class Main {
  public static void main(String[] argsthrows Exception {
    Connection conn = getConnection();
    Statement st = conn.createStatement();
    // st.executeUpdate("drop table survey;");
    st.executeUpdate("create table survey (id int,name varchar(30));");
    st.executeUpdate("insert into survey (id,name ) values (1,'nameValue')");

    st = conn.createStatement();
    ResultSet rs = st.executeQuery("SELECT * FROM survey");

    ResultSetMetaData rsMetaData = rs.getMetaData();

    int numberOfColumns = rsMetaData.getColumnCount();
    System.out.println("resultSet MetaData column Count=" + numberOfColumns);

    st.close();
    conn.close();
  }

  private static Connection getConnection() throws Exception {
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String url = "jdbc:odbc:northwind";
    String username = "";
    String password = "";
    Class.forName(driver);
    return DriverManager.getConnection(url, username, password);
  }
}

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • carlosdl
    The question is not very clear.  What is exactly what you want to accomplish?
    84,720 pointsBadges:
    report
  • Brijesh
    Which database that you want to connect ?
    14,450 pointsBadges:
    report
  • munnyram123456
    ms access database.
    65 pointsBadges:
    report
  • munnyram123456
    sir,
    I have a completed ms access database ,I want's to connect it with my webpage using java program.
    65 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: