Я создал следующий класс в Java, чтобы упростить использование SQLite при написании кода.
import java.sql.*;
public class Dbm {
//We want to use the connection throughout the whole class so it is
//provided as a class level private variable
private Connection c = null;
//This constructor opens or creates the database provided by the argument
// NameOfDatabase
public Dbm(String NameOfDatabase) {
try {
// Database is checked for in project folder, if doesn't exist then creates database
c = DriverManager.getConnection("jdbc:sqlite:" + NameOfDatabase);
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
System.out.println("Opened database successfully");
}
public void CloseDB() {
try {
c.close();
System.out.println("Closed database successfully");
}
catch (Exception e) {
System.out.println("Failed to close database due to error: " + e.getMessage());
}
}
public void ExecuteNoReturnQuery(String SqlCommand) {
// creates a statement to execute the query
try {
Statement stmt = null;
stmt = c.createStatement();
stmt.executeUpdate(SqlCommand);
stmt.close();
System.out.println("SQL query executed successfully");
} catch (Exception e) {
System.out.println("Failed to execute query due to error: " + e.getMessage());
}
}
// this method returns a ResultSet for a query which can be iterated over
public ResultSet ExecuteSqlQueryWithReturn(String SqlCommand) {
try {
Statement stmt = null;
stmt = c.createStatement();
ResultSet rs = stmt.executeQuery(SqlCommand);
return rs;
} catch (Exception e) {
System.out.println("An error has occurred while executing this query" + e.getMessage());
}
return null;
}
}
Вот основной код программы
import java.sql.*;
public class InstaText {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Dbm db = new Dbm("people.db");
ResultSet rs = db.ExecuteSqlQueryWithReturn("select * from people;");
try {
String name = "";
int age = 0;
String address = "";
while (rs.isLast() == false) {
name = rs.getString("name");
age = rs.getInt("age");
address = rs.getString("address");
System.out.println("Name is " + name +" age is " + age + " Address is " + address);
rs.next();
}
} catch (Exception e ) {
System.out.println("Error: " + e.getMessage());
}
db.CloseDB();
}
}
Но когда я его выполняю, я получаю следующий результат:
Opened database successfully
Error: function not yet implemented for SQLite
Closed database successfully
Итак, как мне устранить ошибку:
Ошибка: функция еще не реализована для SQLite
Я запускаю NetBeans Ide с последней версией JDBC на Mac OS Sierra.
Изменить: вот результат после добавления e. printstacktrace(); в уловке заблокировать:
Opened database successfully
Error: function not yet implemented for SQLite
java.sql.SQLException: function not yet implemented for SQLite
Closed database successfully
at org.sqlite.jdbc3.JDBC3ResultSet.isLast(JDBC3ResultSet.java:155)
at instatext.InstaText.main(InstaText.java:24)
Подробнее здесь: https://stackoverflow.com/questions/409 ... for-sqlite
Java sqlite – Ошибка: функция еще не реализована для SQLite ⇐ JAVA
Программисты JAVA общаются здесь
-
Anonymous
1737832612
Anonymous
Я создал следующий класс в Java, чтобы упростить использование SQLite при написании кода.
import java.sql.*;
public class Dbm {
//We want to use the connection throughout the whole class so it is
//provided as a class level private variable
private Connection c = null;
//This constructor opens or creates the database provided by the argument
// NameOfDatabase
public Dbm(String NameOfDatabase) {
try {
// Database is checked for in project folder, if doesn't exist then creates database
c = DriverManager.getConnection("jdbc:sqlite:" + NameOfDatabase);
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
System.out.println("Opened database successfully");
}
public void CloseDB() {
try {
c.close();
System.out.println("Closed database successfully");
}
catch (Exception e) {
System.out.println("Failed to close database due to error: " + e.getMessage());
}
}
public void ExecuteNoReturnQuery(String SqlCommand) {
// creates a statement to execute the query
try {
Statement stmt = null;
stmt = c.createStatement();
stmt.executeUpdate(SqlCommand);
stmt.close();
System.out.println("SQL query executed successfully");
} catch (Exception e) {
System.out.println("Failed to execute query due to error: " + e.getMessage());
}
}
// this method returns a ResultSet for a query which can be iterated over
public ResultSet ExecuteSqlQueryWithReturn(String SqlCommand) {
try {
Statement stmt = null;
stmt = c.createStatement();
ResultSet rs = stmt.executeQuery(SqlCommand);
return rs;
} catch (Exception e) {
System.out.println("An error has occurred while executing this query" + e.getMessage());
}
return null;
}
}
Вот основной код программы
import java.sql.*;
public class InstaText {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Dbm db = new Dbm("people.db");
ResultSet rs = db.ExecuteSqlQueryWithReturn("select * from people;");
try {
String name = "";
int age = 0;
String address = "";
while (rs.isLast() == false) {
name = rs.getString("name");
age = rs.getInt("age");
address = rs.getString("address");
System.out.println("Name is " + name +" age is " + age + " Address is " + address);
rs.next();
}
} catch (Exception e ) {
System.out.println("Error: " + e.getMessage());
}
db.CloseDB();
}
}
Но когда я его выполняю, я получаю следующий результат:
Opened database successfully
Error: function not yet implemented for SQLite
Closed database successfully
Итак, как мне устранить ошибку:
Ошибка: функция еще не реализована для SQLite
Я запускаю NetBeans Ide с последней версией JDBC на Mac OS Sierra.
Изменить: вот результат после добавления e. printstacktrace(); в уловке заблокировать:
Opened database successfully
Error: function not yet implemented for SQLite
java.sql.SQLException: function not yet implemented for SQLite
Closed database successfully
at org.sqlite.jdbc3.JDBC3ResultSet.isLast(JDBC3ResultSet.java:155)
at instatext.InstaText.main(InstaText.java:24)
Подробнее здесь: [url]https://stackoverflow.com/questions/40961934/java-sqlite-error-function-not-yet-implemented-for-sqlite[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия