javagradledbutils

net.proteanit.sql for gradle


I'm trying to open same project in 3 build tools: Maven, Ant and Gradle. It's simple project with sql database, I've already done this via Ant and Maven, unfortunately after adding rs2xml.jar to project module(as I added in Ant and Maven), and import (import net.proteanit.sql.DbUtils;) project doesn't compile. I don't receive any errors from Intellij (no code is red), during gradle task - compileJava the message appears:

"error: package net.proteanit.sql does not exist import net.proteanit.sql.DbUtils;"

It points me to method: table.setModel(DbUtils.resultSetToTableModel(rs));

In build file I added dependecies like: open javafx, javafx graphics, java.swing, apche.ant.

{ public class ExaminationDetails extends JFrame implements ActionListener {

private JPanel contentPane;
private JTable table;
private JTextField search;
private JButton b1, b2, b3;


public void Book() {
    try {
        conn con = new conn();
        String sql = "select * from student";
        PreparedStatement st = con.c.prepareStatement(sql);
        ResultSet rs = st.executeQuery();

        ***table.setModel(DbUtils.resultSetToTableModel(rs));***
        rs.close();
        st.close();
        con.c.close();
    } catch (Exception e) {
    }

}

}

Any help will be appreciated.


Solution

  • if that jar file are in any online repo it would be better to use it but in case you want to use this file then modify your repo as follow

    repositories {
        mavenCentral()
        flatDir {
            dirs 'lib'
        }
    
    

    this will look for the jar inside that folder

    and for your dependencies add this line to it

    implementation name:'rs2xml'
    

    notice name the file without the extension

    Edit:

    if there no certain rule that make you use gradle version 7.1 then it better to use the latest version 7.5 simply run this

     ./gradlew wrapper --gradle-version 7.5
    

    from your project folder or even the ide terminal window

    hope that help and have a nice day :)