CONNECTING DATABASE USING JAVASERVERPAGES (转载)

erp|server

I have given you the source code, how to connect with database from jsp. this is easy and simple.cut and paste the below code and modify according to your requirements.This is esspecially for those who had coding experience in ASP.I have given proper documentation.  

<!--first we've to import the necessary packages-->
<!--importing packages starts-->
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<!--importing packages ends-->
<%
try
{
//loading the drivers
//this code loads JDBD-ODBC Driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//making connection
//The second step in establishing a connection is to have the appropriate
//driver connect to the DBMS. The following line of code illustrates the
//general idea:
String url="jdbc:odbc:test";
//where "test" is the system dsn name
Connection con=DriverManager.getConnection(url, "administrator", "password");
//where "administrator is the username to
//access the database and password is " password"
//DriverManager's getconnection method estabilishes connection
//with the database specified in the JDBC URL
//Then create jdbc statement
Statement stmt = con.createStatement();
String query="CREATE TABLE COFFEES" +
"(COF_NAME VARCHAR(32),"+
"SUP_ID INTEGER,"+
"PRICE FLOAT,"+
"SALES INTEGER,"+
"TOTAL INTEGER)";
//Execute the statement
stmt.executeUpdate(query);
}
catch (Exception e) {}
//give confirmation message
out.println("table coffees created");
%>

时间: 2024-10-29 00:34:42

CONNECTING DATABASE USING JAVASERVERPAGES (转载)的相关文章

如何复制控制文件在ASM实例存储

本文介绍如何在ASM实例的环境下,去复制2个控制文件的过程. 如果在文件系统,相对比较简单了. ##Make sure db is in the archived mode SQL> archive log listDatabase log mode Archive ModeAutomatic archival EnabledArchive destination +ARCH_01/t/Oldest online log sequence 24Next log sequence to archi

ajax调用返回php接口返回json数据的方法(必看篇)

php代码如下: <?php header('Content-Type: application/json'); header('Content-Type: text/html;charset=utf-8'); $email = $_GET['email']; $user = []; $conn = @mysql_connect("localhost","Test","123456") or die("Failed in conn

Paging Database Results in ASP.NET (Prt1)(转载:http:

For More Information on ASP.NET This article examines how to create a databound listbox using ASP.NET. For more information on ASP.NET be sure to check out the articles in the ASP.NET Article Index. The code in this article is based on the Beta 2 ver

Paging Database Results in ASP.NET (Prt1)(转载:http://www.4guysfromrolla.com/)[登级:初级]

asp.net For More Information on ASP.NET This article examines how to create a databound listbox using ASP.NET. For more information on ASP.NET be sure to check out the articles in the ASP.NET Article Index. The code in this article is based on the Be

Paging Database Results in ASP.NET (Prt2)(转载:http:

Paging Database Results in ASP.NET By Scott Mitchell -------------------------------------------------------------------------------- Read Part 1 -------------------------------------------------------------------------------- In Part 1 we looked at

Paging Database Results in ASP.NET (Prt2)(转载:http://www.4guysfromrolla.com/)[登级:初级]

asp.net Paging Database Results in ASP.NET By Scott Mitchell -------------------------------------------------------------------------------- Read Part 1 -------------------------------------------------------------------------------- In Part 1 we lo

7.1 Connecting to a MySql database from Python

install mysql-connector-python $ sudo pip3 install --extra-index-url https://pypi.python.org/pypi/mysql-connector-python/2.0.4 mysql-connector-python 本地开启mysql数据库,在terminal中输入python3,导入模块并创建连接 >>> import mysql.connector >>> conn = mysql.

[Linux转载]Linux 操作

Linux操作命令集合 参考:http://www.cnblogs.com/rollenholt/archive/2012/09/01/2667184.html   正在运行的内核和系统信息 # uname -a # 获取内核版本(和BSD版本) # lsb_release -a # 显示任何 LSB 发行版版本信息 # cat /etc/SuSE-release # 获取 SuSE 版本 # cat /etc/debian_version # 获取 Debian 版本 使用 /etc/DIST

Beginner: Using Servlets to display, insert and update records in database.(1)

servlet Displaying Records from the Database with Java Servlets. Overview : In this article I'll explain each step you need to know to display records from the database using Servlets. The steps for displaying records in JSP pages and Java Beans are