Most voted "jdbc" questions
Java Database Connectivity or JDBC is a set of classes and interfaces (API) written in Java that send SQL statements to any relational database.
Learn more…213 questions
Sort by count of
-
20
votes3
answers14671
viewsWhat is the difference between Statement and Preparedstatement?
When I paid for the database chair, we worked with the bank alone, with no connection to an application that interacted externally with the DBMS. Only then was presented the JDBC(Java Database…
-
13
votes1
answer1462
viewsUse Resultset without knowing the column type
I need to use a Resultset that returned the data of a query in the database. I’m making a very generic class, it can be used in any table, so I don’t know what kind of data it’s returning. For…
-
10
votes1
answer2621
viewsWhy use Class.forName when connecting to the database?
For database connection, in addition to the inclusion of the JDBC driver, most articles and examples use the static method Class.forName(String). See the example with Mysql:…
-
9
votes1
answer503
viewsQuestions about Mysql integration with Java
I am creating a system in Netbeans, using the Java language and the Mysql database. I wrote the following code to make the connection between the program and the database: public class Conexao {…
-
8
votes3
answers11171
viewsHow to return the ID of a record right after it is inserted?
I am making a Java application in conjunction with a Mysql database and would like to know what would be the best command to return an auto database increment ID right after the record is inserted.…
-
6
votes1
answer156
views -
6
votes1
answer2639
viewsCall PL/SQL precedent with object collection
Consider the following types: CREATE TYPE meu_tipo AS OBJECT ( meu_id NUMBER(6), meu_nome VARCHAR2(200) ); CREATE TYPE meu_tipo_tabela AS TABLE OF meu_tipo; And the following package: create or…
-
6
votes1
answer169
viewsIs it possible to inform the size of the VARCHAR in a Namedparameter?
I’m working with a tuning of an SQL Server database. Through the query below, I can see how the bank executed some of my heaviest queries. SELECT TOP 30 deqt.TEXT AS Query, last_execution_time FROM…
-
5
votes2
answers305
viewsWhy is this Resultset returning null?
If I run a query in the database returns result, however, when running java code, assigning the result to a Resultset, the same appears to be empty. You can help me? PreparedStatement ps =…
-
5
votes1
answer246
viewsSpring MVC getJdbcTemplate Insert in Oracle return column value
I have a project in Spring MVC, I’m using the getJdbcTemplate to make Insert’s. Only I do not insert the key Primary in Oracle from a sequence and need that value to re-enter another table where…
-
4
votes1
answer617
viewsHow to set a char in a Preparedstatement?
My typical variable is a char how to set this in Preparedstatement ? PreparedStatement ps = conexao.prepareStatement(sql); ps.setString(1, veiculo.getTipoCombustivel());…
-
4
votes1
answer624
views"The resultset is closed" error with Preparedstatement
I’m getting it when I’m walking through a ResultSet and get other ResultSets: public class BpaDetDao extends DaoAbstract<BpaDetBean> { public static final String // TODO Colocar campos no…
-
4
votes2
answers567
viewsTest without "fouling" (adding data) the database
I am having trouble doing integration testing. I test my database functions. My web application does not use any framework database connection and I am unable to do tests without fouling my…
-
4
votes1
answer837
viewsHow to organize CRUD methods for each table?
I would like to know how to organize the CRUD (create, read, update, delete) methods of each class in Java. An example, to better understand: Suppose we have the classes Funcionario, Cliente and…
-
4
votes1
answer698
viewsJDBC - does not connect to Mysql database
In java I created a project in which I use the drive mysql-Connector-java-5.1.40-bin. jar, in this project I created a class with a form to register course and mysql I created a database called…
-
4
votes1
answer356
viewsDatabase Locked Sqlite/Java error
I have the following problem: in an Insert that I am trying to accomplish, I don’t know if it is an error in the database or something in the java programming, but every time I try to perform an…
-
3
votes2
answers3658
views"Connection refused" error when connecting to Postgresql
Error happens after entering login and password: "Deuorg.postgresql.util.Psqlexception: Connection refused. Check that the hostname and port are correct and that the postmaster is Accepting TCP/IP…
-
3
votes1
answer1561
viewsjava.lang.Nullpointerexception Error in JDBC Connection with WS + Postgres
I am creating a WS that connects to a DB Postgresql and performs a query in a single table. I try to run it locally, but the problem is when running the application gives the following error: HTTP…
-
3
votes1
answer1635
viewsJDBC Sqlite - Java
Good afternoon, How do I make the connection to the Sqlite BD? I made the connection class like this. package model; import java.sql.Connection; import java.sql.DriverManager; import…
-
3
votes1
answer81
viewsDB oracle Closed Connection
Introducing I am developing an application and have to add data to an oracle database that is local. Using JDBC I connect try (Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@" +…
-
3
votes1
answer185
viewsWhat is Context and Generated Keys?
I’d like to know what exactly context class connection (I’ve seen methods in relation to this like getConnectionFromContext, or something like that) and Generated Keys as the Preparedstatment…
-
3
votes1
answer778
viewsJava/ Sqlserver transaction divided into multiple methods
I have a method that performs several Prepared Statements, only two of them in methods of other classes. In my method, I have the object connection, and if I want to start a transaction, I have to:…
-
3
votes1
answer48
viewsProfile network java (jdbc)
What tool can I use to evaluate the response time of a request (jdbc) Ex: query = "SELECT * FROM v$version WHERE banner LIKE '%Oracle%'"; ResultSet rs = stmt.executeQuery(query); // linha de cima ⋀…
-
3
votes1
answer4660
viewsForeign keys in java
I’m having a little trouble implementing the foreign keys in my example. Can someone help me assemble the DAO class? Cidadedao.java public class CidadeDAO { private final Connection connection;…
-
3
votes0
answers610
viewsFirebird 3.0 connection problem with Java 1.8
I am having problems trying to connect to Firebird 3.0 using Jaybird 2.2.7, when performing the test with Firebird 2.5 I can make the connection to the database, but when trying to do it with…
-
3
votes1
answer755
viewsHow to convert java.util.Date to java.sql.Date keeping up hours, minutes and seconds?
I am doing a program in Java. In it I get a date of type java.util.Date, but I need it in java.sql.Date so that I can enter into the database. But on that date, I have hour, minute and second and I…
-
3
votes1
answer8135
viewsWays to get bank values with Resultset
Ways to get values from the Java database (JDBC). public static Connection getConnection(){ /* 1. Faz a conexao com a base de dados */ /* 2. Retorna qual banco ira trabalhar */ Connection…
-
3
votes1
answer176
viewsWhy does my Drivermanager return null Pointer?
Postgresql 9.4 I execute my class Noticias(). Within the method public static void main() class Noticias() a method is called getConexao(); When I execute pagecontroller?=p=noticias in the browser…
-
3
votes1
answer51
viewsSend data to database
I’m studying for a java test on database and I’m very confused, I was making a program based on another, I made a registration screen and it works perfect, the only thing missing is to send and I do…
-
3
votes0
answers92
viewsIntercept SQL s on a custom JDBC
You can create a custom implementation based on JDBC to intercept all sql s executed in the application? I did not find anything very concrete about this in Google, I made a simple test just…
-
3
votes0
answers76
viewsHow to make pincode activator via serial?
I’m trying to do brush validator (serial), but I don’t know how to do it. I have two tables: "validation" and "maturity". In the "validation" table, you have the following fields: id(int),…
-
3
votes1
answer128
viewsProcessing SQL statements with JDBC
I am trying to use JDBC, but having difficulties with the proper use of language. I would like to move the sql code down to java, and I need help with SELECT. Regarding the variables sql1, sql2,…
-
3
votes0
answers454
viewsHTTP Status 500 - Request Processing failed; nested Exception is java.lang.Illegalargumentexception: Datasource must not be null
When making a query in a dao class, the following error appears: my spring-context.xml is: <mvc:interceptors> <bean…
-
3
votes1
answer208
viewsProblem calling Drivemanager.getConnection?
I am studying Java with database and I am doing some examples. On the PC with Windows I used a code and it worked, no problem occurred, now I returned to use Linux and the same code is giving error…
-
3
votes1
answer113
viewsConnect external bank to UI Designer in Bonitasoft Community
I’m using the tool Bonitasoft to develop a project BPM, I have a database Postgresql that through a connection JDBC I was able to enter and change records by Bonitasoft, but I can’t select the…
-
3
votes1
answer552
viewsUpdate command does not work
I have three tables in a database, and I have a method called alteraLinhaTabela where I try to update one of the three tables at a time by identifying it by the variable tabela. I also pass two more…
-
3
votes2
answers244
views -
3
votes1
answer790
viewsCheck whether the field is null in java and mysql
How do I check if a database field is filled or null? Do you have a Resultset method that does this check? In this case it is a date field. PreparedStatement ps = connection.prepareStatement("SELECT…
-
3
votes1
answer154
viewsError for Importing JDBC from sqlServer with Maven
In my java web application ,I needed to add a connection to a sql server database, so I put it as a dependency on Maven as described below: <dependency>…
-
3
votes2
answers503
viewsDeleting data from a MYSQL table with Java
I’m trying to delete data from a table with Java but for some reason the code is not working. Excerpt from the code below: public void excluir(ModeloObjeto modelo) throws Exception{ Connection…
-
3
votes0
answers104
viewsHow to proceed to implement a Preparedstatement on Android?
We are using the Sqldroid to work as a JDBC driver for Android. However, Sqldroid is an envelope for Android API calls, and this API does not deal well with nulls. So, for us to use…
-
2
votes1
answer577
views -
2
votes1
answer847
viewsPut WS Restful Project into Production
I’m a beginner in Java and these . jar, . War, etc businesses are news to me. I did my first Restful Webservice project and added 2 *.jars, Gson and JDBC.postgres. I want to put into production (on…
-
2
votes1
answer642
viewsLabel is not displayed
I created a label where it would contain the status of the process of connection with the database, but it does not appear and I have no idea why this happens, already three days that I look at the…
-
2
votes1
answer64
viewsRequestmapping to a large URL
Wanted to know how I make one @RequestMapping for a large URL. In case I wanted to map the word authenticate.…
-
2
votes2
answers175
viewsNullpointerexception error, where is the error?
I wanted to know where the mistake is. I read that the mistake NullPointerException is when we try to access a variable that wasn’t initialized, I just didn’t find this error in my code. import…
-
2
votes1
answer63
viewsError in user registration, changing user instead insert
My problem is the following, I saw that when I edit a record , it works, the registration is changed, but when I want to register a new user, it falls in the editing condition, it edits the…
-
2
votes1
answer153
viewsHow does the process of accessing a database work?
I started studying databases and to access a certain database with JDBC a driver is required for each DBMS (Mysql, SQL Server, Oracle), and the access is done on disk, but how is this process done?…
-
2
votes1
answer37
viewsNullpointerexception when trying to log into the system inside netbeans
Soon after I did some icon overwrites on the main screen and on the About screen, error occurred NullPointerException, I have no idea how to continue and continue the course I am doing. I use Mysql,…
-
2
votes2
answers2008
views"No value specified for Parameter 1" when executing Preparedstatement
I’m testing a insert here and the following error appears to me: Exception in thread "main" java.sql.Sqlexception: No value specified for Parameter 1 Dao package modelo; import java.sql.Connection;…