Questions tagged [JDBC] (102)

2
answers

How to fix Can't use query methods that take a query string on a PreparedStatement?

Want to add a new value, but there is a bug though, if you go to the table itself, the values shown: org.postgresql.util.PSQLException: Can't use query methods that take a query string on a PreparedStatement. at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:95) at M2.main(M2.java:22) Error ...
jaiden_Sipe asked April 7th 20 at 09:29
2
answers

Not connected connection = getConnection(URL, USERNAME, PASSWORD);. How to connect a database to the environment?

Mounts the database. If you zakamentuj line connection = getConnection(URL, USERNAME, PASSWORD);, everything works. Can't understand what the error is. PS pattern as it was fucking darkness of errors, working with multiple directories, but the fix does not work<?xml version="1.0" encoding="UTF-8"?> <project xmlns=...
Lorenza_Larson asked April 4th 20 at 13:04
1
answer

What error java.sql.SQLException: No suitable driver found for jdbs:mysql://localhost:3306/mydbtest?

The full text of the output in the console: com.mysql.cj.jdbc.Driver@6267c3bb Driver registered successfully The connection is not established java.sql.SQLException: No suitable driver found for jdbs:mysql://localhost:3306/mydbtest at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702) at java.sql/java.s...
Amina_Mann asked April 4th 20 at 01:27
1
answer

How to maintain a connection with the current table H2 database?

Good day ! I'm only familiar with the H2 database and here is the question. Here a connection is created:Connection connection=null; try{ Class.forName("org.h2.Driver"); connection= DriverManager.getConnection("jdbc:h2:~/test"); System.out.println("Connection ok"); Statement stat = connection.createStatement(); stat...
Tristian18 asked April 2nd 20 at 17:34
2
answers

Error when adding record to mysql database Java jdbc?

Hello everyone, I'm a beginner learning java was faced with a problem, namely when adding a record to a mysql error occurs. The code itselfprivate void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try { String name = jTextField1.getText(); Statement statement = con.createStatement(); String query = "INSERT...
dustin asked March 25th 20 at 11:32
1
answer

Error when calling a method getImportedKeys?

Guys, Hello! Need to foreign key.Class.forName("org.postgresql.Driver"); Connection connection = DriverManager.getConnection(configDataBase.getUrl(), configDataBase.getName(), configDataBase.getPassword()); Statement statement = connection.createStatement(); ResultSet rsSql = statement.executeQuery("select * from table_nam...
Devan49 asked March 24th 20 at 10:59
1
answer

Why not JdbcTemplate executes query with parameters?

The task is to write a parameterized SQL query using JDBC and Template'. Create a table:jdbcTemplate.execute(" CREATE TABLE test (id BIGINT PRIMARY KEY, test_id VARCHAR(50));"); Declare the parameters:Map<String, String> parameters = new HashMap(); parameters.put("test_id", "test"); Update:jdbcTemplate.update( "INSE...
Wade_Spin asked March 24th 20 at 10:58
1
answer

What is different about Hibernate from spring Data and, in principle, the tools database?

Hello, I was doing a project and I thought it was used for Spring Data here is part of my pom <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> ... like connected the spring data but propertah...
Jackie.Hoeger57 asked March 24th 20 at 10:32
0
answer

Java + JDBC + PostgreSQL — how to update a record if exists or add it if it is not?

Have a collection with many objects. The collection is displayed in the table. The offline user can add and delete records, and update the previously obtained via SELECY * FROM ... I want to implement the function "Save All", in which the program was to for all collections and updated records in the database, if they exist,...
loraine asked March 19th 20 at 19:12
0
answer

As from different threads to address a single instance of the class managing the database?

The point is, I have a class(DBmanager) which works with the database( Adds, deletes, modifies the string, verifies them, etc.). There's a second class that is a server (ServerChat), that each newly connected user creates a new thread to work with it. But the DBmanager object if we have one and it is created when you creat...
geovanny_Kautzer97 asked March 17th 20 at 13:04