Files
qbit-printing/src/main/java/com/kingsrook/qbits/printing/DriverDataSource.java
T
james.maesandClaude Sonnet 5.5 e4639e3cca chore: integrate printing standards and strict Java compiler checks
Preserve current rendering, operator and retained-source behavior while integrating script quality, meaningful headers and strict Error Prone/NullAway contracts. Production and test compilation and the 189-case verification gate pass with zero failures and one intentional workload skip.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: James Maes <james@kof22.com>
2026-11-01 16:51:18 -06:00

122 lines
2.7 KiB
Java

/*
* QQQ - Low-code Application Framework for Engineers.
* Copyright (C) 2021-2025. Kingsrook, LLC
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
* contact@kingsrook.com
* https://github.com/Kingsrook/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.printing;
import javax.sql.DataSource;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Logger;
import org.jspecify.annotations.Nullable;
/*******************************************************************************
** Minimal JDBC data source for demos; production applications supply a pool.
*******************************************************************************/
public record DriverDataSource(String url, String user, String password) implements DataSource
{
@Override
public Connection getConnection() throws SQLException
{
return DriverManager.getConnection(url, user, password);
}
@Override
public Connection getConnection(String username, String secret) throws SQLException
{
return DriverManager.getConnection(url, username, secret);
}
@Override
public @Nullable PrintWriter getLogWriter()
{
return null;
}
@Override
public void setLogWriter(PrintWriter writer)
{
// This simple demo data source does not log JDBC calls or credentials.
}
@Override
public void setLoginTimeout(int seconds)
{
DriverManager.setLoginTimeout(seconds);
}
@Override
public int getLoginTimeout()
{
return DriverManager.getLoginTimeout();
}
@Override
public Logger getParentLogger()
{
return Logger.getLogger("com.kingsrook.qbits.printing");
}
@Override
public <T> T unwrap(Class<T> type) throws SQLException
{
if(type.isInstance(this))
{
return type.cast(this);
}
throw new SQLException("Not a wrapper");
}
@Override
public boolean isWrapperFor(Class<?> type)
{
return type.isInstance(this);
}
@Override
public String toString()
{
return "DriverDataSource[credentials redacted]";
}
}