Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am a beginner, learning Java and now I don't know how to solve this problem in my JDBC program.
Code:
sqliteConnection.java

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

public class sqliteConnection {
     Connection conn = null;
     
     public static Connection dbConnector()
     {
    	 try
    	 {
    		 Class.forName("org.sqlite.JDBC");
    		 Connection conn = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\danil\\Desktop\\Student.sqlite");
    		 JOptionPane.showMessageDialog(null, "Successfully connected to Database");
    		 return conn;
    	 }
    	 catch(Exception e)
    	 {
    		 JOptionPane.showMessageDialog(null, e);
    		 return null;
    	 }
     }
	
}


Login.java

Java
import java.awt.EventQueue;

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

public class Login {

	private JFrame frame;

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

	Connection connection = null;
	
	/**
	 * Create the application.
	 */
	public Login() {
		initialize();
		connection = sqliteConnection.dbConnector();
	          }

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

}


Console
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Module sqlite.jdbc contains package org.sqlite.date, module org.xerial.sqlitejdbc exports package org.sqlite.date to sqlite.jdbc


What I have tried:

I tried everything, tried solving by myself(but I can't realy I am beginner) ,asked questions on groups (every group deleted post :( )
Posted
Updated 12-Aug-22 1:43am

1 solution

Take a look at SQlite Java - How To Use JDBC To Interact with SQLite[^]. And I suggest you create a simple console application to get the SQLite code working first.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900