#java.sql.connection not importing

1 messages · Page 1 of 1 (latest)

glacial hollyBOT
#

@arctic oar has a question:

mangoflood

Hi , just curios , why isn't my java code importing java.sql.connection
it is saying I need to add dependency there

#

<@&987246399047479336> please have a look, thanks.

arctic oar
nimble tendon
#

if you alt+enter on the Connection in try-with-resources cant you import it?

#

also what jdk are u using

bright pollen
#

probably not selected any jdk

#

or smth

nimble tendon
#

the sql package included in jdk right?

bright pollen
nimble tendon
#

@arctic oar show us the project structure screen

bright pollen
#

the project structure is found under File > Project Structure

#

ctrl + alt+ shift + S

arctic oar
bright pollen
#

seems fine for me

nimble tendon
#

same here

#

@arctic oar hover on the Connection error

bright pollen
#

and share the pom.xml

arctic oar
#

Says Cannot resolve symbol 'Connection'

#
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>jdbcTutorial</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>20</maven.compiler.source>
        <maven.compiler.target>20</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>2.2.224</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>5.0.1</version>
        </dependency>

    </dependencies>

</project>
nimble tendon
arctic oar
#

It just shows maven dependency

bright pollen
#

wdym?

nimble tendon
#

?

arctic oar
#

Wait , let me screenshot what the hover says , will be back in few minutes

nimble tendon
#

ok

arctic oar
#

apologies for inconvenience

bright pollen
#

all good

nimble tendon
#

np

arctic oar
#

@nimble tendon @bright pollen

#

On clicking adding Add Maven Depedency

bright pollen
#

Maybe invalidate caches in IntelliJ

arctic oar
bright pollen
arctic oar
#

Oh well , new issue

#

java.sql.SQLException: No suitable driver found for jdbc:h2:mem
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:708)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:253)
at jdbcTutorial.main(jdbcTutorial.java:7)

#

@bright pollen

bright pollen
#

so it wont be available in the normal source

arctic oar
bright pollen
#

remove the scope for the h2 dependency

#

then reload maven

arctic oar
#

yeah yeah figured

#

thanks anyways