Variables not called properly and not displaying
Hi,
My first JFrame i have written the following code:
"""""public class seamless_frame extends javax.swing.JFrame {
public String User1;
public String SerName1;
public String SourcePassword1;
public String ConnectionString1;
public String SourceDbms1;
public void SourceValues(){
SerName1= ServerName.getText();
ConnectionString1=CString.getText();
User1= UserName.getText();
char[] SPassword=SourcePwd.getPassword();
SourcePassword1 = new String(SPassword);
System.out.println( User1);
System.out.println( ConnectionString1);
System.out.println( SerName1);
System.out.println( SourcePassword1);
}
public seamless_frame() {
initComponents();
Container content = getContentPane();
content.setBackground(Color.white);
}"""""
after declaration of this code i call my class and method in second frame as shown below
Second JFrame code:
"""""""seamless_frame SourceObject = new seamless_frame();
SourceObject.SourceValues();
try
{
Class.forName("net.sourceforge.jtds.jdbc.Driver");
String url = "jdbc:jtds:sqlserver://"+SourceObject.SerName1+"/"+SourceObject.ConnectionString1;
Properties props = new Properties();
props.setProperty("user",SourceObject.User1);
props.setProperty("password",SourceObject.SourcePa ssword1);
props.setProperty("namedPipe","true");
Connection conn = DriverManager.getConnection(url,props);
JOptionPane optionPane = new JOptionPane("Connected to Database", JOptionPane.INFORMATION_MESSAGE);
JDialog dialog = optionPane.createDialog("Seamless Access");
dialog.setVisible(true);
System.out.println("Try again1");
conn.close();
}
catch (Exception e)
{
JOptionPane optionPane = new JOptionPane("Invalid user credentials entered: Please re-enter them correctly", JOptionPane.ERROR_MESSAGE);
JDialog dialog = optionPane.createDialog("Seamless Access");
dialog.setVisible(true);
System.out.println("Try again2");
}
System.out.println("Try again3");
"""""""
My question is i am not able to pass the variables to the second JFrame and connect to database. Please help me out in correcting this code and getting the output
thanks in advance
Regards
Sandeep