当前位置: 代码迷 >> Java相关 >> yue = rs.getString("LeaveMoney" );
  详细解决方案

yue = rs.getString("LeaveMoney" );

热度:666   发布时间:2006-03-15 07:10:00.0
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  

----------------解决方案--------------------------------------------------------
你这段代码不全吧,把全部代码帖出来才好看啊
----------------解决方案--------------------------------------------------------
因为你的Label4.setText(CardID);中的CardID是由
staticMessage sm=new staticMessage(CardID);
传进去的,所以显示。
“以下两个句子为什么没有查询结果?
yue = rs.getString("LeaveMoney" );
userName = rs.getString( "Name" );”
就可能是你的select语句的问题了。

----------------解决方案--------------------------------------------------------
  相关解决方案