Hi,
In this program, i have established the connection and it even works. i get a value from the table and checked it with the given value . if both r same, i have to assign that value to a string. But if i try assigning the value to a string variable, it goes out of the try statement to the catch statement..can u please help me what's wrong and why its not working....than k you.
i have given the print statement inside the if condition..its working. but the variable assignment is not working. - try
-
{
-
login_name=usert.getText().trim();
-
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
-
String url = "jdbc:odbc:sakthi";
-
con = (Connection)DriverManager.getConnection(url,"sakthi","");
-
Statement stmt=con.createStatement();
-
System.out.println("Connection :"+con);
-
System.out.println("Connection is created!"+login_name);
-
String run=("select * from logg");
-
ResultSet rs=stmt.executeQuery(run);
-
while(rs.next())
-
{
-
-
if(rs.getString("user").trim().equalsIgnoreCase(login_name.trim()))
-
{
-
System.out.println("hello");
-
//uid=rs.getString("user");
-
// System.out.println(uid);
-
-
}
-
else
-
{
-
System.out.println(" bye");
-
}
-
-
}con.close();
-
}
-
catch(Exception s)
-
{
-
System.out.println("Doesn't establish the connection!");
-
System.exit(0);
-
}
-
-
}
1 1439
Hi,
In this program, i have established the connection and it even works. i get a value from the table and checked it with the given value . if both r same, i have to assign that value to a string. But if i try assigning the value to a string variable, it goes out of the try statement to the catch statement..can u please help me what's wrong and why its not working....than k you.
i have given the print statement inside the if condition..its working. but the variable assignment is not working. - try
-
{
-
login_name=usert.getText().trim();
-
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
-
String url = "jdbc:odbc:sakthi";
-
con = (Connection)DriverManager.getConnection(url,"sakthi","");
-
Statement stmt=con.createStatement();
-
System.out.println("Connection :"+con);
-
System.out.println("Connection is created!"+login_name);
-
String run=("select * from logg");
-
ResultSet rs=stmt.executeQuery(run);
-
while(rs.next())
-
{
-
-
if(rs.getString("user").trim().equalsIgnoreCase(login_name.trim()))
-
{
-
System.out.println("hello");
-
//uid=rs.getString("user");
-
// System.out.println(uid);
-
-
}
-
else
-
{
-
System.out.println(" bye");
-
}
-
-
}con.close();
-
}
-
catch(Exception s)
-
{
-
System.out.println("Doesn't establish the connection!");
-
System.exit(0);
-
}
-
-
}
- if(rs.getString("user").trim().equalsIgnoreCase(login_name.trim()))
Retrieves data from column user. Then inside the if block you are trying to call rs.getString("u ser") again. That according to the specs may not yield the correct results. Only call getString once for that given column. If you have done s.printStackTra ce(); (you should) in your catch block you will have seen the exception that was thrown because of that.
And I spent the whole day yesterday pointing that out.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Steve Jorgensen |
last post by:
If you've ever employed custom error numbers and messages in you programs,
you've probably ended up with code similar to what I've ended up with in
the past something like...
<code>
public Const xyzcErrNumBase As Long = 500
Public Const xyzcErrNumHeyDontDoThat = xyzcErrNumBase + 1
Public Const xyzcErrTxtHeyDontDoThat = "Hey! Don't do that!"
|
by: Leon Shaw |
last post by:
Need help understanding?
Server Error in '/solo' Application.
----------------------------------------------------------------------------
----
Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
|
by: Fir5tSight |
last post by:
Hi All,
I used the following code in C#:
using System.Drawing;
//blah blah blah
Bitmap bmp = new Bitmap();
|
by: johnny |
last post by:
I have the following PHP code. I am using PHP 5.1.6.
$req =& new HTTP_Request($this->accessUrl);
I am getting the following errors:
Strict Standards: Assigning the return value of new by reference is
deprecated in c:\mysite\lib\simpleTest.php on line 80
Can anyone tell why is this? Does it mean assigning the return value
of new by reference is not supported in PHP 5.1.6?
|
by: Steven Spencer \(Spinalogic\) |
last post by:
Dim dlg As New dlgChangeDate
Dim fromdate As DateTime = dlg.GetaDate(System.DateTime.Now, "Please Enter
the Start of the Holiday")
If (Not fromdate.CompareTo(New DateTime(1, 1, 1, 1, 1, 1, 1)) = 0) Then
While IsDateBetweenShifts(fromdate, cboHolidayDoctors.SelectedValue)
MsgBox("The date you have entered does not occur between the
| |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |