spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

JdbcChatMemory not compatible with MSSQL Server

Open xchopin opened this issue 7 months ago • 0 comments
trafficstars

Bug description

Cannot use JdbcChatMemory with a MSSQL Server

Incorrect syntax near 'LIMIT'.
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:270) ~[mssql-jdbc-12.8.1.jre11.jar:na]
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1735) ~[mssql-jdbc-12.8.1.jre11.jar:na]
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:675) ~[mssql-jdbc-12.8.1.jre11.jar:na]
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:594) ~[mssql-jdbc-12.8.1.jre11.jar:na]
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7745) ~[mssql-jdbc-12.8.1.jre11.jar:na]
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:4391) ~[mssql-jdbc-12.8.1.jre11.jar:na]
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:276) ~[mssql-jdbc-12.8.1.jre11.jar:na]
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:246) ~[mssql-jdbc-12.8.1.jre11.jar:na]

Environment 1.0.0-M7

Steps to reproduce Add a JdbcChatMemory as an advisor to a ChatClient with a MSSQL Server

Expected behavior Return the elements

Minimal Complete Reproducible example


// Create a chatclient for example:  
@Bean
	public ChatClient chatClient(ChatClient.Builder builder) {
		return builder.defaultSystem(SYSTEM)
			.defaultAdvisors(new MessageChatMemoryAdvisor(new JdbcChatMemory(JdbcChatMemoryConfig.builder().jdbcTemplate(jdbcTemplate).build())))
				.build();
	}


// then use the chatclient 

chatClient.prompt(prompt).call().content();

xchopin avatar Apr 19 '25 03:04 xchopin