Copying default tags to a database

As the title says, I’m attempting to copy the tags from the default tag provider into an empty database. However, I’m not sure if what I have (shown below) is actually reading the tags. The project builds, but I don’t see any change to my database (which seems to have a valid connection according to the gateway webpage.

public class TagListener implements TagChangeListener {
    	TagPath path;
    	SRConnection dbconnection;
    	GatewayContext context;
    	public TagListener(TagPath path) {
    		this.path= path;
    		// TODO Auto-generated constructor stub
    	}

    	private final Logger log = Logger.getLogger(getClass());

    	@Override
    	public TagProp getTagProperty() {
    		// TODO Auto-generated method stub
    		return null;
    	}

    	@Override
    	public void tagChanged(TagChangeEvent arg0) {
    		List <TagPath> list= new ArrayList<TagPath>();//creates list with type TagPath
    		list.add(path);//adds path to list
    		List<QualifiedValue> tags= context.getTagManager().read(list);//reads list to access tags
    		log.error("Value : "+ tags.get(0).getValue());
    		datacopy(tags);//
    		
    	}
    	public void readingTest() throws IOException{
    		TagPath myPath= TagPathParser.parse("[default]");
    		TagListener listener=new TagListener(myPath) {

    		};
    		List <TagPath> list2= new ArrayList<TagPath>();
    		lista.add(myPath);
    		context.getTagManager().subscribe(myPath, listener);
    		System.out.println(list2);
    	}
    	public void datacopy(List ltags) {
    		try {
				dbconnection=context.getDatasourceManager().getConnection("ModTest");//connect to db
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
    		String query = String.format("INSERT INTO [ModTAGS].[dbo].[ModuleTags] VALUES ('%s')",ltags);//insert tag list
    		try {
				dbconnection.runPrepQuery(query);//insert tag list
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
    		
    	}
    }

Any help is appreciated.

In case anyone has time, I’ve made some edits, but I’m still don’t see a change in my database.

//Inside public void tagChanged
List<QualifiedValue> tags= GatewayHook.context.getTagManager().read(list);//reads list to access tags
int tagvalue = (int)tags.get(0).getValue();
Quality tagqual = tags.get(0).getQuality();
Date tagdate = tags.get(0).getTimestamp();
datacopy(tagpath,tagvalue,tagqual,tagdate);
//
public void datacopy(TagPath tp,int value, Quality qual, Date date) {
    		try {
				dbconnection = GatewayHook.context.getDatasourceManager().getConnection("ModTest");//connect to db
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
    		String query = String.format("INSERT INTO [ModTAGS].[dbo].[ModuleTags] (TagName, TagValue, TagQuality,TagtimeStamp) VALUES ('%s',%d,'%s','%s')",tp,value,qual,date);//insert tag list
    		try {
				dbconnection.runPrepQuery(query);//insert tag list
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
    		
    	}

For anyone who needs it, I moved readingTest() and datacopy() to my GatewayHook (the rest of TagListener remains it’s own class/.java file). The database now updates.