-2
我有一個問題,我的查詢我不知道如何處理甲骨文,但是當我嘗試相同的代碼的SQL它的工作,但它顯示我上面的錯誤編譯我認爲問題是在查詢中,請有人幫助,如果知道如何處理這個。 感謝SQL狀態[null];錯誤代碼[17004];無效的列類型;嵌套的異常是java.sql.SQLException:無效列類型
//一流
package com.caveofprogramming.spring.test;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Component;
@Component
("offersDao")
public class OffersDAO {
private JdbcTemplate jdbc;
@Autowired`enter code here`
public void setDataSource(DataSource jdbc) {
this.jdbc = new JdbcTemplate(jdbc);
}
public boolean create(Offer offer) {
BeanPropertySqlParameterSource params = new BeanPropertySqlParameterSource(offer);
return jdbc.update("INSERT INTO offers " + " (id, name, email, text) "
+ " VALUES " + " (:id, :name, :email, :text) ", params) == 1;
}
}
//二等
package com.caveofprogramming.spring.test;
public class Offer {
private int id;
private String name;
private String email;
private String text;
public Offer() {
}
public Offer(int id, String name, String email, String text) {
this.id = id;
this.name = name;
this.email = email;
this.text = text;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
@Override
public String toString() {
return "Offer [id=" + id + ", name=" + name + ", email=" + email
+ ", text=" + text + "]";
}
}
//第3主類
package com.caveofprogramming.spring.test;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.CannotGetJdbcConnectionException;
public class App {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext(
"com/caveofprogramming/spring/test/beans/beans.xml");
OffersDAO offersDao = (OffersDAO) context.getBean("offersDao");
try {
Offer offer1 = new Offer(10, "khan", "[email protected]", "GG");
Offer offer2 = new Offer(11, "khan", "[email protected]", "GG");
Offer offer3 = new Offer(12, "khan", "[email protected]", "GG");
offersDao.create(offer1);
offersDao.create(offer2);
offersDao.create(offer3);
} catch (CannotGetJdbcConnectionException ex) {
System.out.println("Unable to connect to database");
} catch (DataAccessException ex) {
System.out.println(ex.getMessage());
System.out.println(ex.getClass());
}
((ClassPathXmlApplicationContext) context).close();
}
}
如果您認爲問題與查詢有關,那麼實際包含它可能是一個好主意......包含表定義也是一個好主意(一個或多個)查詢正在擊中的表格。 – JonK
沒有發佈相關的代碼,沒有人可以幫助你。 Downvoting。您可以通過閱讀http://stackoverflow.com/help/how-to-ask以及如何通過閱讀以下內容創建示例來參考如何提出問題:http://stackoverflow.com/help/mcve –
@JonK謝謝兄弟,我想包括我的整個Java類,但由於一些奇怪的原因不工作..查詢是返回jdbc.update(「INSERT INTO offers」+「(id,name,email,text)」+「VALUES」+「 (:id,:name,:email,:text)「,params)== 1; – Faisal