6 Replies - 340 Views - Last Post: 10 July 2019 - 02:37 PM Rate Topic: -----

#1 dako   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 60
  • Joined: 01-July 19

SQLite manager

Posted 10 July 2019 - 01:54 PM

Hi there guys (and gals :) ) I am having some trouble finding a SQlite manager that is free and understandable. I have been trying with DB Browser but when I try to use it with eclipse to link Java's jdbc to the table and use a query to insert data or check for data, I get an error. And I dont really quite know what it is. But I remember using some other manager that I created a table with that just so happened to work. Unfortunately I don't remember the name of that application! So if anyone could either tell me what I am doing wrong with DB Browser or tell me of an application I could use to create a database with tables that I can link with a Java program I would be very greatful.

Thanks for your time!

Is This A Good Question/Topic? 0
  • +

Replies To: SQLite manager

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15226
  • View blog
  • Posts: 60,944
  • Joined: 12-June 08

Re: SQLite manager

Posted 10 July 2019 - 02:09 PM

It helps when you copy/paste your error.

hard to guess what you were using before.. a plethora comes up with "sqlite viewer".
Was This Post Helpful? 0
  • +
  • -

#3 dako   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 60
  • Joined: 01-July 19

Re: SQLite manager

Posted 10 July 2019 - 02:19 PM

View Postmodi123_1, on 10 July 2019 - 02:09 PM, said:

It helps when you copy/paste your error.

hard to guess what you were using before.. a plethora comes up with "sqlite viewer".


 java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=Login,when=1562792614217,modifiers=Button1] on javax.swing.JButton[,213,211,85x21,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$[email protected],flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Login,defaultCapable=true] 


now I switched to sqlite manager and it is giving me some error window also that I don't understand. Would you like a screenshot?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15226
  • View blog
  • Posts: 60,944
  • Joined: 12-June 08

Re: SQLite manager

Posted 10 July 2019 - 02:23 PM

Again.. any error messages you can provide help remove the guesswork.
Was This Post Helpful? 0
  • +
  • -

#5 dako   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 60
  • Joined: 01-July 19

Re: SQLite manager

Posted 10 July 2019 - 02:27 PM

View Postmodi123_1, on 10 July 2019 - 02:23 PM, said:

Again.. any error messages you can provide help remove the guesswork.


Okay I fixed the error from the SQLite manager. But I still get the error I mentioned above

 
java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=Login,when=1562793123010,modifiers=Button1] on 
javax.swing.JButton[,213,211,85x21,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$[email protected],flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Login,defaultCapable=true]


Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15226
  • View blog
  • Posts: 60,944
  • Joined: 12-June 08

Re: SQLite manager

Posted 10 July 2019 - 02:34 PM

That's the error from the actual crash log? Console?
Was This Post Helpful? 0
  • +
  • -

#7 dako   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 60
  • Joined: 01-July 19

Re: SQLite manager

Posted 10 July 2019 - 02:37 PM

View Postmodi123_1, on 10 July 2019 - 02:34 PM, said:

That's the error from the actual crash log? Console?


yeah I originally had the catch do a

JOptionPane.showMessageDialog(null, e); but then changed it to a System.out.println(e);
So I could copy and paste the error.

Here is the code.

import java.awt.EventQueue;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class DBGui {

	private JFrame frame;
	private JTextField textUsername;
	private JPasswordField textPassword;
	dbManager db = new dbManager();

	Connection conn = db.dbConnector();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					DBGui window = new DBGui();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public DBGui() {
		initialize();
		
		
	
	}
	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JLabel lblNewLabel = new JLabel("Username:");
		lblNewLabel.setBounds(101, 75, 46, 13);
		frame.getContentPane().add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("Password:");
		lblNewLabel_1.setBounds(101, 144, 46, 13);
		frame.getContentPane().add(lblNewLabel_1);
		
		textUsername = new JTextField();
		textUsername.setBounds(213, 72, 96, 19);
		frame.getContentPane().add(textUsername);
		textUsername.setColumns(10);
		
		JButton btnLogin = new JButton("Login");
		btnLogin.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					String query = "select * from sample where username=? and password=?";
			
					
					PreparedStatement pst = conn.prepareStatement(query);
					
					pst.setString(0, textUsername.getText());
					pst.setString(1, textPassword.getText());
					
					
					ResultSet rs = pst.executeQuery();
					int count = 0;
					while(rs.next()) {
					count++;
					if(count == 0)
			
						if(count == 1 )
							JOptionPane.showMessageDialog(null, "Username correct!");
							else
								
								JOptionPane.showMessageDialog(null, "Incorrect username or password!");

					
				JOptionPane.showMessageDialog(null, "Welcome!");
					} }
				 catch (Exception e2) {
					// TODO: handle exception
					 System.out.println(e);
					JOptionPane.showMessageDialog(null, e);
				}
			
			}});
		btnLogin.setBounds(213, 211, 85, 21);
		frame.getContentPane().add(btnLogin);
				
		textPassword = new JPasswordField();
		textPassword.setEchoChar('*');
		textPassword.setBounds(213, 141, 96, 19);
		frame.getContentPane().add(textPassword);
	
}
}






and also

import java.sql.*;
import javax.swing.*;

public class dbManager {
Connection c = null;
	public static Connection dbConnector() {
		try {
			Class.forName("org.sqlite.JDBC");
			Connection c = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\dakot\\OneDrive\\Documents\\Databases\\mydatabase.sqlite");
			JOptionPane.showMessageDialog(null, "Connection made!");
			return c;
			
		} catch (Exception e) {
			
		JOptionPane.showMessageDialog(null, e);
		return null;
		}
		
		
	}
}



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1