| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 580 人关注过本帖
标题:yue = rs.getString("LeaveMoney" );
只看楼主 加入收藏
yfzsj
Rank: 1
等 级:等待验证会员
帖 子:242
专家分:2
注 册:2005-9-22
收藏
 问题点数:0 回复次数:2 
yue = rs.getString("LeaveMoney" );

package card;

import java.sql.*;

public class staticMessage
{
public staticMessage( String id )
{
this.CardID = id;
try
{
con = cardConnect.getconn();
query = con.createStatement();
queryString = "Select * From users Where LeaveMoney=? and Name=?";
rs = query.executeQuery( queryString ); //得到查询结果
if( rs.next() )
{
yue = rs.getString("LeaveMoney" );
userName = rs.getString( "Name" );

exist = true;
}
} catch( Exception ee )
{} finally
{
cardConnect.close( rs );
cardConnect.close( query );
cardConnect.close( con );
}
}

public boolean isExist()
{
return exist;
}

public static String getUserName()
{
return userName;
}

public static String getLevel()
{
return yue;
}

String queryString;
Connection con;
Statement query;
ResultSet rs;
static String CardID;
public static String userName;
public static String yue;
static boolean exist = false;
}

以下两个句子为什么没有查询结果?
yue = rs.getString("LeaveMoney" );
userName = rs.getString( "Name" );
package card;

import java.awt.*;
import javax.swing.*;
import java.sql.*;

public class queryPanel extends JPanel
{
public queryPanel(String id)
{
try
{
this.CardID=id;
jbInit();
} catch( Exception exception )
{
exception.printStackTrace();
}
}

private void jbInit() throws Exception
{
this.setLayout( null );
jLabel1.setFont( new java.awt.Font( "Dialog", Font.PLAIN, 18 ) );
jLabel1.setHorizontalAlignment( SwingConstants.CENTER );
jLabel1.setText( "用户名:" );
jLabel1.setBounds( new Rectangle( 64, 46, 76, 18 ) );
jLabel2.setFont( new java.awt.Font( "Dialog", Font.BOLD, 18 ) );
jLabel2.setForeground( Color.red );
jLabel2.setBounds( new Rectangle( 207, 41, 159, 23 ) );
jLabel3.setFont( new java.awt.Font( "Dialog", Font.PLAIN, 18 ) );
jLabel3.setHorizontalAlignment( SwingConstants.CENTER );
jLabel3.setText( "卡 号:" );
jLabel3.setBounds( new Rectangle( 63, 117, 75, 30 ) );
jLabel4.setFont( new java.awt.Font( "Dialog", Font.BOLD, 18 ) );
jLabel4.setForeground( Color.red );
jLabel4.setBounds( new Rectangle( 209, 118, 151, 26 ) );
jLabel5.setFont( new java.awt.Font( "Dialog", Font.PLAIN, 18 ) );
jLabel5.setHorizontalAlignment( SwingConstants.CENTER );
jLabel5.setText( "余 额:" );
jLabel5.setBounds( new Rectangle( 63, 193, 81, 19 ) );
jLabel6.setFont( new java.awt.Font( "Dialog", Font.BOLD, 18 ) );
jLabel6.setForeground( Color.red );
jLabel6.setBounds( new Rectangle( 208, 191, 173, 25 ) );
this.add( jLabel1 );
this.add( jLabel3 );
this.add( jLabel6 );
this.add( jLabel4 );
this.add( jLabel2 );
this.add( jLabel5 );

staticMessage sm=new staticMessage(CardID);
jLabel2.setText(staticMessage.getUserName());
jLabel4.setText(CardID);
jLabel6.setText(staticMessage.getLevel());
}

JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
//自定义变量
String CardID;
}


为什么 只能显示出 Label4.setText(CardID);的查询结果?

搜索更多相关主题的帖子: getString yue 
2006-03-15 07:10
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
收藏
得分:0 
你这段代码不全吧,把全部代码帖出来才好看啊

可惜不是你,陪我到最后
2006-03-15 10:01
farseer
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2006-3-25
收藏
得分:0 
因为你的Label4.setText(CardID);中的CardID是由
staticMessage sm=new staticMessage(CardID);
传进去的,所以显示。
“以下两个句子为什么没有查询结果?
yue = rs.getString("LeaveMoney" );
userName = rs.getString( "Name" );”
就可能是你的select语句的问题了。
2006-03-25 10:38
快速回复:yue = rs.getString("LeaveMoney" );
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053430 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved