Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@hbk-UY6MQq • Jun 17, 2008
u talking abt JDBC?? -
@elric-7vzoqS • Jun 17, 2008
You could be more specific, like in which part you need help? Database connectivity or GUI design? -
@jaichan-vZRNGJ • Jul 18, 2008
Hi friend first of all u understand the database connectivity -
@neha-3vibjn • Jul 23, 2008
hi!
This is all related to database connectivity.
You'll have to maintain a database for the same recording the logins and the passwords etc and connect it to your file. -
@nirajkumar-6nokRG • Jul 24, 2008
You can follow this step
1. You need to create a table to store this information
2. Learn JDBC its easy ... make the connection.. u will find lots of tutorial on this .
3. Make a simple UI is java swing ....
thats it ... if u need further then reply ... i mean wat kind of problem u r facing ..... paste the error msg here ...(if u have any) -
@komputergeek-Yf5hJ4 • Oct 21, 2008
These are two classes from my project:
Login.java : import javax.swing.*; import java.awt.event.*; import java.sql.*; public class Login { static JFrame f; static JPanel p1; static JPanel p2; static JPanel p3; static JLabel lUserName; static JTextField tUserName; static JLabel lPassword; static JPasswordField pPassword; static JButton bLogin; static JButton bCancel; public static void showLoginWindow () { f = new JFrame ("Login"); p1 = new JPanel (); p2 = new JPanel (); p3 = new JPanel (); lUserName = new JLabel ("User Name : "); tUserName = new JTextField (20); lPassword = new JLabel ("Password : "); pPassword = new JPasswordField (20); bLogin = new JButton ("Login"); bLogin.setToolTipText ("Click here to Login"); bLogin.setMnemonic('L'); bLogin.addActionListener (new ActionListener () { public void actionPerformed (ActionEvent e) { try { Connection con = null; Statement stmt; ResultSet rs; boolean flag=false; con = DBConnect.getCon (); stmt = con.createStatement (); rs = stmt.executeQuery ("Select * from USERS where USERNAME='" + tUserName.getText () + "' and PASSWORD = '" + pPassword.getText() + "'" ); while(rs.next()) { if(rs.getString("USERNAME").equals(tUserName.getText()) && rs.getString("PASSWORD").equals(pPassword.getText())) { flag=true; } } if(flag==false) { Result_AnalysisFrame frame= new Result_AnalysisFrame(); frame.setVisible(true); f.hide(); } else { JOptionPane.showMessageDialog(null,"Login Failed !!!","Login Fail",JOptionPane.WARNING_MESSAGE); } } catch (Exception ex) { JOptionPane.showMessageDialog (null, ex, "Error", JOptionPane.INFORMATION_MESSAGE); } } } ); bCancel = new JButton ("Cancel"); bCancel.setToolTipText ("Click here to Exit"); bCancel.setMnemonic('C'); bCancel.addActionListener (new ActionListener () { public void actionPerformed (ActionEvent e) { System.exit (0); } } ); p1.add (lUserName); p1.add (tUserName); p2.add (lPassword); p2.add (pPassword); p3.add (bLogin); p3.add (bCancel); Box bx1 = Box.createVerticalBox (); bx1.add (p1); bx1.add (p2); bx1.add (p3); f.getContentPane ().add (bx1); f.setVisible (true); f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); f.setLocation (380, 280); f.pack (); f.setResizable (false); } } DBConnect.java : import java.sql.*; import oracle.jdbc.*; import javax.swing.*; public class DBConnect { public static Connection getCon () { Connection con = null; String url = "jdbc:odbc:RA2"; try { Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection (url, "RA", "RA"); } catch (Exception e) { JOptionPane.showMessageDialog (null, e, "Error", JOptionPane.INFORMATION_MESSAGE); } return con; } } -
@xero-28ehVN • Oct 21, 2008
the info is not sufficient to rectify. Looking at code(the jdbc ones) it seems more like a driver issue. But before proceeding further, i think you should first go thru the basics of jdbc and the types of drivers available with databases.
I'll just give you intro with the 4 types of drivers ->
1. JDBC ODBC driver - this is the driver you have used in your program. This driver converts the jdbc calls into odbc acting as a bridge. So make sure have configured the odbc correctly. eg if you are using oracle as db so you have to configure the odbc for oracle. (for more reference, google 😁)
2. Native-API partly Java technology-enabled driver - in this the java converts the jdbc calls into db api calls.
3. Net-protocol fully Java technology-enabled driver - in this JDBC API calls is translated into a DBMS-independent net protocol which is then translated to a DBMS protocol by a server
4. Native-protocol fully Java technology-enabled driver - converts JDBC technology calls into the network protocol used by DBMSs directly. This is a pure java based driver !
The above was just informative, don't need to think deep into it. It won't harm to know.
So the take-away is that your code is using the driver of type 1 so first you must check the configuration for Db specific odbc configuration.