2

I'm trying to understand how to work with Spring JDBC framework.

I've found example on http://www.tutorialspoint.com/spring/spring_jdbc_example.htm and trying to implement in my own project.

This is my example

package test;

import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class TestJDBCTemplate {
       private DataSource dataSource;
       private JdbcTemplate jdbcTemplateObject;

       public void setDataSource(DataSource dataSource) {
          this.dataSource = dataSource;
          this.jdbcTemplateObject = new JdbcTemplate(dataSource);
       }

}

But I got the problem with

import javax.sql.DataSource

Access restriction: The type 'DataSource' is not API (restriction on required library 'C:\Program Files (x86)\Java\jre1.8.0_31\lib\rt.jar')

What's wrong with this import and how to fix it. This kind of import I've seen in all examples about Spring JDBC framework.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Alex Zhulin
  • 1,239
  • 2
  • 22
  • 42

1 Answers1

14

Go to build path settings of your project in eclipse. Remove JRE system library. Add it again. This should resolve your error.

Sezin Karli
  • 2,517
  • 19
  • 24