1

I have JDBC driver connected to my Eclipse project. According to MS manual I need to set claspath for JDBC. How to do this in Eclipse? I suppose it should be somewhere in run configuration, but I can't find it. Where I can set classpath in Eclipse?

I need to set CLASSPATH environment variable and not just add jar file. I can connect to SQL server from my project while LOG4J library can't. I suppose since it loads driver at runtime.

vico
  • 17,051
  • 45
  • 159
  • 315
  • I don't need to set jar files location, I need to set CLASSPATH run time environment variable – vico Jul 05 '18 at 15:12
  • you add jars to the classpath. In your case it would be JDBC's jar. PS- Use build tool like maven/gradle. – Shanu Gupta Jul 05 '18 at 15:14
  • I'm using maven and log4j and JDBC driver are added. Projects compiles, but run complains `log4j:ERROR Failed to excute sql java.sql.SQLException: No suitable driver found for "jdbc:sqlserver://localhost:1433;databaseName=ERP_IDMS"` – vico Jul 05 '18 at 15:22
  • see https://stackoverflow.com/questions/5616898/java-sql-sqlexception-no-suitable-driver-found-for-jdbcmicrosoftsqlserver – Shanu Gupta Jul 05 '18 at 15:26
  • @Shanu Gupta this is not the same issue. I can connect to SQL server from my project while LOG4J library can't. I suppose since it loads driver at runtime – vico Jul 05 '18 at 15:29
  • Oh alright. You might want to include these details in the question. – Shanu Gupta Jul 05 '18 at 15:31
  • Forget about the `CLASSPATH` environment variable, most ways of executing Java programs don't use it, and relying on it will only make for brittle programs – Mark Rotteveel Jul 06 '18 at 08:46
  • it's no me, it log4j needs `CLASSPATH` – vico Jul 06 '18 at 13:45

1 Answers1

1

Project menu -> Properties -> Java Build Path

You can add .jar files to your classpath in the Libraries tab

java-addict301
  • 3,220
  • 2
  • 25
  • 37