@arctic oar has a question:
Hi , just curios , why isn't my java code importing java.sql.connection
it is saying I need to add dependency there
1 messages · Page 1 of 1 (latest)
@arctic oar has a question:
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.
if you alt+enter on the Connection in try-with-resources cant you import it?
also what jdk are u using
the import is already there
probably not selected any jdk
or smth
idk maybe context action could show smth
the sql package included in jdk right?
yes
@arctic oar show us the project structure screen
the project structure is found under File > Project Structure
ctrl + alt+ shift + S
It is showing me this
seems fine for me
and share the pom.xml
I hovered over import java.sql.Connection
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>
does it show anything here like i have
Nope
It just shows maven dependency
wdym?
?
Wait , let me screenshot what the hover says , will be back in few minutes
ok
apologies for inconvenience
all good
np
Maybe invalidate caches in IntelliJ
don't know how to do it
cehck this screenshot
worked thanks
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
your scope is test
so it wont be available in the normal source
oh so what should I do?