After spending hours searching for the cause and consulting with my seniors, I got a solution, in short, I just had to code the incoming result set into UTF-8 (Unicode) encoding, here's how I did it:
Create a column table with nvarchar () as the data type into which you must insert bidirectional text, and then use the following queries to insert, update, select and delete (there is only one column in the example table, i.e. nvarchar () data type )
INSERT INTO table_name VALUES(N'عربی ABC') SELECT FROM table_name WHERE column_name LIKE N'عربی%' UPDATE table_name SET column_name = N'عرب' WHERE column_name like N'%ABC' DELETE FROM table_name WHERE column_name = N'عرب'
while in Java there are many ways to connect to SQL and execute queries, such as using the JDBC-ODBC bridge in Windows to connect to SQL, this is how I do it
Connection cn=null; ResultSet rs=null; PreparedStatement ps=null; String password = *******; String data; public static Connection conn() throws ClassNotFoundException,SQLException { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url="jdbc:odbc:library_management"; return DriverManager.getConnection(url,"sa", password ); }
Note that to execute any query that does not create a result set, we simply use the PreparedStatement.execute()
function
source share