607071749a3e001d1877d06bec62b1ea
来自「自己做的一个火车票售票网站是课程设计 用的是servlet+jsp 数据库是m」· 代码 · 共 133 行
TXT
133 行
package com.ajax;
import java.io.*;
import java.util.*;
import java.sql.*;
import com.jdbc.*;
public class Ajax {
Statement psmt=null;
ResultSet rt =null;
String sql =null;
DataBaseConnection dbc = new DataBaseConnection();
public String getMessage(){
String rs=null;
int i=0;
sql="select number,name from ajax where number1 is null order by name";
try{
psmt=dbc.getConnection().createStatement();
rt=psmt.executeQuery(sql);
rs="";
while (rt.next()) {
rs = rs+ "<option value=\"" + rt.getString(1) + "\""; //从1开始的
if (i == 0) {
rs = rs + " selected ";
}
rs = rs + ">" + rt.getString(2) + "</option>";
i++;
}
}
catch(Exception e){
}
finally{
try{
psmt.close();
}
catch(Exception e){
}
dbc.close();
}
return rs;
}
public String getMessage(String code){
String rs=null;
sql="select distinct name from ajax where number1='"+code+"' ";
try{
psmt=dbc.getConnection().createStatement();
rt=psmt.executeQuery(sql);
rs="";
while (rt.next()) {
//rs = rs + rt.getString(1)+","+ rt.getString(2)+"$";
rs = rs + rt.getString(1)+"$";
}
}
catch(Exception e){
}
finally{
try{
psmt.close();
}
catch(Exception e){
}
dbc.close();
}
return rs;
}
public String getMessage1(String code){
String rs=null;
sql="select distinct number from ajax where name='"+code+"' ";
try{
psmt=dbc.getConnection().createStatement();
rt=psmt.executeQuery(sql);
rs="";
while (rt.next()) {
rs = rs + rt.getString(1)+"$";
}
}
catch(Exception e){
}
finally{
try{
psmt.close();
}
catch(Exception e){
}
dbc.close();
}
return rs;
}
public String getMessage2(String code,String code1,String code2){
String rs=null;
sql="select distinct number from ajax where name='"+code+"' ";
try{
psmt=dbc.getConnection().prepareCall(sql);
rt=psmt.executeQuery(sql);
rs="";
while (rt.next()) {
rs = rs + rt.getString(1)+"$";
}
}
catch(Exception e){
}
finally{
try{
psmt.close();
}
catch(Exception e){
}
dbc.close();
}
return rs;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?