|
I showed you how to find information on reading CSV files, no doubt you can do the same for XML.
Use the best guess
|
|
|
|
|
I know how to read xml file but I have a problem with this file.
|
|
|
|
|
peniya wrote: I know how to read xml file but I have a problem with this file. Then you need to explain what that problem is; please don't expect people to guess it.
Use the best guess
|
|
|
|
|
How to write this code?
I have .csv file. Content of file like as follow:
A,B
B,C
A,F
F,G
G,H
B,D
I have to read this file and output should be :
A _ B _ C
| |_ D
|_F _ G_ H
How to write this code to get this output?
modified 30-Jul-13 12:41pm.
|
|
|
|
|
peniya wrote: I have to use swing You don't use swing to read a file. Look at these links[^].
Use the best guess
|
|
|
|
|
For output I should use swing.
and I know how to read .csv file, but my problem is with output.
how to get that output.
|
|
|
|
|
That question is impossible to answer in a forum like this. Go and find some swing tutorials and learn about what features are available to hlep you format your output.
Use the best guess
|
|
|
|
|
hi i have problem selecting the numbers that is not in the single/double qoutes . let say we have this text below .
123
<style color="#767676">
8787
i want to select just the 123 and 8787 , nothing else
how should i do this with regular expression in javascript
|
|
|
|
|
|
private static void insertRecord() throws SQLException
{
Connection con = null;
Statement statement = null;
try
{
PreparedStatement PS = Connectionstring().prepareStatement("INSERT INTO LoginDetails(Username,Password) VALUES (?,?)");
String User = tf_Uname.getText();
String _Pass = new String(tf_pass.getPassword());
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA-256");
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
}
md.update(_Pass.getBytes());
byte byteData[] = md.digest();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < byteData.length; i++) {
sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
}
System.out.println("Hex format : " + sb.toString());
StringBuffer hexString = new StringBuffer();
for (int i=0;i<byteData.length;i++)
{
String hex=Integer.toHexString(0xff & byteData[i]);
if(hex.length()==1) hexString.append('0');
hexString.append(hex);
}
System.out.println("Hex format : " + hexString.toString());
PS.setString(1, User);
PS.setString(2, _Pass);
PS.executeUpdate();
JOptionPane.showMessageDialog(null,"Your Data has been Inserted","Data Inserted",JOptionPane.INFORMATION_MESSAGE);
}
catch (SQLException e)
{
System.out.println(e.getMessage());
}
finally
{
if (statement != null)
{
statement.close();
JOptionPane.showMessageDialog(null,"Statement is closed","Statement",JOptionPane.INFORMATION_MESSAGE);
}
if (con != null)
{
con.close();
JOptionPane.showMessageDialog(null,"Connection is closed!","Connection",JOptionPane.INFORMATION_MESSAGE );
}
}
}
I'm getting the right output but could not able to save the hash password into the database it's being stored as a Text.
|
|
|
|
|
Hello chdboy please check this line
PS.setString(1, User);
PS.setString(2, _Pass);
PS.executeUpdate();
you have provided normal text to user and password field
While you need to provide hex code in this line no 1 and 2
|
|
|
|
|
Thanks a lot ...now let's see if there is a problem in getting hex code back to the string when user enter details .
|
|
|
|
|
You shouldn't need to, that means anyone else can, and your system is not secure. Passwords should use one-way hashes so they can never be converted back to the original string. See Secure Password Authentication Explained Simply[^].
Use the best guess
|
|
|
|
|
I am new to Java and Web Development. I need to build a Java server App, which has to interact with MySQL DB stored procedures and fetch rows and return to client.
1. Client can be from Http request from web browser
2. An Android app
3. Desktop app
4. and others
Now my question is; should the server App be
1.JSP
2.Servlet
3.WebService
Load balancing should be done for Server App, and server App is going to be 3-tire
Please advice the Pro/Cons in each case.
|
|
|
|
|
This question is far too broad for a technical forum such as this. You need to do your own research and study before deciding which technologies will be best to address your problem.
Use the best guess
|
|
|
|
|
I want to validate Username and Password matching from my sql Database,but it didn't work.Even if the text fields are blank it does not give any error.
private static void selectfromdb() throws SQLException
{
Statement stmt = Connectionstring().createStatement();
ResultSet rs = stmt.executeQuery("SELECT Username,Password FROM LoginDetails where Username='"+tf_Fname+"' AND Password ='"+tf_Lname+"'");
while (rs.next())
{
String x = tf_Fname.getText();
String pass = new String(tf_Lname.getPassword());
if (x.equals(rs.getString("Username")))
{
if (pass.equals(rs.getString("Password")))
{
JOptionPane.showMessageDialog(null,"Login Successful! ","Success",JOptionPane.WARNING_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(null,"Login UNSuccessful! ","UNSuccessful",JOptionPane.WARNING_MESSAGE);
}
}
}
}
|
|
|
|
|
Try this
private static void selectfromdb() throws SQLException
{
Statement stmt = Connectionstring().createStatement();
ResultSet rs = stmt.executeQuery("SELECT Username,Password FROM LoginDetails where Username='"+tf_Fname+"' AND Password ='"+tf_Lname+"'");
rs.last();
int rowcount = rs.getRow();
if(rowcount ==0){
JOptionPane.showMessageDialog(null,"Login UNSuccessful! ","UNSuccessful",JOptionPane.WARNING_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null,"Login Successful! ","Success",JOptionPane.WARNING_MESSAGE);
}
}
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Blue_Boy wrote:
ResultSet rs = stmt.executeQuery("SELECT Username,Password FROM LoginDetails where Username='"+tf_Fname+"' AND Password ='"+tf_Lname+"'");
It is really bad form to give sample code that can lead to SQL injection[^].
Use the best guess
|
|
|
|
|
I didn't gave example to use query which is able to inject, the user used by him/herself, i just gave solution how to manage login case.
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
In both the cases even if it's right password it shows "Login UNSuccessful"
|
|
|
|
|
Use your debugger to step through the code and see what values your variables contain at each stage.
Use the best guess
|
|
|
|
|
The row count is 0 when I debug it....but I'm using the same username and password what's in the database,why is it not accepting it?
|
|
|
|
|
chdboy wrote: The row count is 0 when I debug it....but I'm using the same username and password what's in the database,why is it not accepting it? I have no idea since I have no access to your system. You need to investigate further to discover what is happening.
Use the best guess
|
|
|
|
|
Now I have changed the code
PreparedStatement preparedStatement = Connectionstring().prepareStatement(
"Select Username from dbo.LoginDetails where Username = ? and Password =?");
String User = tf_Fname.getText();
String _Pass = new String(tf_Lname.getPassword());
preparedStatement.setString(1, User);
preparedStatement.setString(2, _Pass);
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next())
{
System.out.println("Username is "+ resultSet.getString(1)+"Password is "+resultSet.getString(2));
}
But now it's picking up the right Username from the table ,if I don't use
+"Password is "+resultSet.getString(2) in the Print line,and if I use that I get an error
com.microsoft.sqlserver.jdbc.SQLServerException: The index 2 is out of range.
|
|
|
|
|
I guess that you need to look more closely at the contents of your ResultSet and its individual property items. Check with your debugger and also the documentation for the classes that you are working with.
Use the best guess
|
|
|
|